結果
問題 | No.592 括弧の対応 (2) |
ユーザー | femto |
提出日時 | 2017-11-10 22:23:24 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 267 ms / 5,000 ms |
コード長 | 464 bytes |
コンパイル時間 | 1,692 ms |
コンパイル使用メモリ | 169,512 KB |
実行使用メモリ | 4,568 KB |
最終ジャッジ日時 | 2023-08-16 02:36:47 |
合計ジャッジ時間 | 3,132 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 263 ms
4,412 KB |
testcase_02 | AC | 267 ms
4,568 KB |
testcase_03 | AC | 261 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int ans[200000]; int main(){ cin.tie(0); ios::sync_with_stdio(false); #ifdef LOCAL std::ifstream in("in"); std::cin.rdbuf(in.rdbuf()); #endif int N; string s; cin >> N >> s; stack<int> st; for(int i = 0; i < N; i++){ if(s[i] == '(') st.push(i); else{ ans[st.top()] = i; ans[i] = st.top(); st.pop(); } } for(int i = 0; i < N; i++){ cout << ans[i] + 1 << endl; } }