結果

問題 No.592 括弧の対応 (2)
ユーザー kotatsugamekotatsugame
提出日時 2017-11-13 02:14:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 286 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 71,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 19:40:01
合計ジャッジ時間 2,006 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 270 ms
5,376 KB
testcase_02 AC 271 ms
5,376 KB
testcase_03 AC 262 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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],n;
stack<int>P;
main()
{
	cin>>n>>s;
	for(int i=0;i<n;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<n;i++)cout<<c[i]<<endl;
}
0