結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
|
提出日時 | 2022-10-01 05:12:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 473 bytes |
コンパイル時間 | 2,004 ms |
コンパイル使用メモリ | 198,756 KB |
最終ジャッジ日時 | 2025-02-07 20:01:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; string S; cin >> N >> S; stack<int> st; vector<int> ans(N, -1); rep(i,N) { if(S[i] == '(') st.push(i); else { int x = st.top(); st.pop(); ans[x] = i; ans[i] = x; } } rep(i,N) cout << ans[i] + 1 << "\n"; }