結果

問題 No.592 括弧の対応 (2)
ユーザー Naoyk1212
提出日時 2017-11-10 22:58:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 267 ms / 5,000 ms
コード長 357 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 65,600 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 13:16:39
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

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