結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
|
提出日時 | 2019-08-18 22:19:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 294 ms / 5,000 ms |
コード長 | 391 bytes |
コンパイル時間 | 2,248 ms |
コンパイル使用メモリ | 197,512 KB |
最終ジャッジ日時 | 2025-01-07 14:13:20 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#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;}