結果
問題 | No.592 括弧の対応 (2) |
ユーザー | はまやんはまやん |
提出日時 | 2017-11-10 22:57:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 5,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 1,546 ms |
コンパイル使用メモリ | 170,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 13:15:15 |
合計ジャッジ時間 | 2,125 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N; string S; int ans[201010]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> S; stack<int> s; rep(i, 0, N) { if (S[i] == '(') s.push(i); else { int j = s.top(); s.pop(); ans[i] = j; ans[j] = i; } } rep(i, 0, N) printf("%d\n", ans[i] + 1); }