結果

問題 No.592 括弧の対応 (2)
ユーザー cielciel
提出日時 2017-11-11 23:43:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 340 bytes
コンパイル時間 1,020 ms
コンパイル使用メモリ 74,324 KB
実行使用メモリ 4,532 KB
最終ジャッジ日時 2023-08-16 07:51:31
合計ジャッジ時間 1,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 25 ms
4,388 KB
testcase_02 AC 24 ms
4,532 KB
testcase_03 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;

int main(){
	int n,k;
	cin>>n;
	string s;
	cin>>s;
	vector<int>v(s.size());
	stack<int>st;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(')st.push(i);
		else{
			int x=st.top();st.pop();
			v[x]=i,v[i]=x;
		}
	}
	for(auto &e:v)printf("%d\n",e+1);
}
0