結果

問題 No.592 括弧の対応 (2)
ユーザー newlife171128newlife171128
提出日時 2017-12-24 16:00:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 259 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 73,064 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 23:49:41
合計ジャッジ時間 1,909 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 255 ms
5,376 KB
testcase_02 AC 243 ms
5,376 KB
testcase_03 AC 259 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>

using namespace std;

int pair_pair[200001];

int main() {

	int n =0;
	cin>>n;

	string s;
	cin>>s;

	stack<int> p;

	for(int i=0; i<s.length(); i++){
		if(s[i] == '('){
			p.push(i);
		}
		if(s[i] == ')'){
			pair_pair[p.top()] =i+1;
			pair_pair[i] = p.top()+1;
			p.pop();
		}
	}
	for(int i=0; i<s.length(); i++){
		cout<<pair_pair[i]<<endl;
	}
return 0;
}
0