結果
問題 | No.592 括弧の対応 (2) |
ユーザー | aaaaaaiu |
提出日時 | 2019-08-18 22:19:33 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 275 ms / 5,000 ms |
コード長 | 391 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 199,112 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-09 02:44:23 |
合計ジャッジ時間 | 3,994 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 275 ms
6,944 KB |
testcase_02 | AC | 271 ms
6,948 KB |
testcase_03 | AC | 269 ms
6,948 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; string s; cin>>n>>s; int a[n]; stack<int> st; for (int i=0;i<n;i++) { if (s[i]=='(') st.push(i); else { int b=st.top(); st.pop(); a[b]=i+1; a[i]=b+1; } } for (int x:a) cout<<x<<endl; return 0; }