結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
![]() |
提出日時 | 2017-11-11 00:27:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 1,725 ms |
コンパイル使用メモリ | 173,644 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 16:10:10 |
合計ジャッジ時間 | 2,935 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 1 |
ソースコード
#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()<<endl; st1.pop(); } } } return 0; }