結果

問題 No.592 括弧の対応 (2)
ユーザー Naoyk1212Naoyk1212
提出日時 2017-11-10 22:58:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 357 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 65,272 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-08-16 03:37:53
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<stack>

int main(){
	int a;
	std::string s;
	std::cin >> a >> s;

	std::stack<int> st;

	std::vector<int> v(a);
	for(int i = 0; i < a; i++){
		if(s[i] == '(') st.push(i);
		else{
			v[st.top()] = i;
			v[i] = st.top();
			st.pop();
		}
	}

	for(int i = 0; i < a; i++){
		std::cout << v[i] + 1 << std::endl;
	}
}
0