結果

問題 No.592 括弧の対応 (2)
ユーザー newlife171128
提出日時 2017-12-24 16:00:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 273 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 73,076 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-17 18:34:01
合計ジャッジ時間 2,130 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

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