結果
問題 | No.592 括弧の対応 (2) |
ユーザー | Julius Caesar |
提出日時 | 2017-11-10 23:04:14 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 262 ms / 5,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 742 ms |
コンパイル使用メモリ | 61,924 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-03 13:21:50 |
合計ジャッジ時間 | 1,724 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 254 ms
5,376 KB |
testcase_02 | AC | 262 ms
5,376 KB |
testcase_03 | AC | 252 ms
5,376 KB |
ソースコード
#include <iostream> #include <string> #include <stack> int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); int N; std::string str; std::cin >> N >> str; int answer[200000] = {}; std::stack<int> stack; for(int i = 0; i < N; ++i){ if(str[i] == '('){ stack.push(i); } else{ answer[stack.top()] = i + 1; answer[i] = stack.top() + 1; stack.pop(); } } for(int i = 0; i < N; ++i){ std::cout << answer[i] << std::endl; } return 0; }