結果

問題 No.592 括弧の対応 (2)
ユーザー kotatsugame
提出日時 2017-11-13 02:11:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 295 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 63,076 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 23:25:32
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<stack>
using namespace std;
string s;
int c[1<<18];
stack<int>P;
main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='(')
		{
			P.push(i);
		}
		else
		{
			int a=P.top();P.pop();
			c[a]=i+1,c[i]=a+1;
		}
	}
	for(int i=0;i<s.size();i++)cout<<c[i]<<endl;
}
0