結果

問題 No.592 括弧の対応 (2)
ユーザー agisagis
提出日時 2017-11-11 00:25:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 172,176 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 15:03:56
合計ジャッジ時間 1,998 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	vector<int>num(N);
	rep(i, N)num[i] = i + 1;
	int flag = 0;
	stack<int>st1,st2;
	int cnt = 0;
	rep(i, N) {
		if (S[i] == '(')cnt++;
		else cnt--;
		st1.push(num[i]);
		if (cnt == 0) {
			while (!st1.empty()) {
				cout << st1.top();
				st1.pop();
			}
		}
	}
	cout << endl;
	return 0;
}
0