結果
問題 | No.592 括弧の対応 (2) |
ユーザー | agis |
提出日時 | 2017-11-11 00:40:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 252 ms / 5,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 173,640 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-05-03 15:05:08 |
合計ジャッジ時間 | 2,677 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 231 ms
6,944 KB |
testcase_02 | AC | 252 ms
6,940 KB |
testcase_03 | AC | 239 ms
6,944 KB |
ソースコード
#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; stack<int>st1; vector<int>num(N); rep(i, N) { if (S[i] == '(')st1.push(i + 1); else { num[st1.top()-1] = i + 1; num[i] = st1.top(); st1.pop(); } } rep(i, N)cout << num[i] << endl; return 0; }