結果
問題 | No.592 括弧の対応 (2) |
ユーザー | ngtkana |
提出日時 | 2020-03-16 10:38:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 2,049 ms |
コンパイル使用メモリ | 204,424 KB |
実行使用メモリ | 5,332 KB |
最終ジャッジ日時 | 2023-08-18 16:14:15 |
合計ジャッジ時間 | 2,744 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 17 ms
5,072 KB |
testcase_02 | AC | 16 ms
5,332 KB |
testcase_03 | AC | 14 ms
4,608 KB |
ソースコード
#include<bits/stdc++.h> using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n;std::cin>>n; std::stack<lint>stack; std::vector<lint>a(n); for(lint i=0;i<n;i++){ char c;std::cin>>c; if(c=='(')stack.push(i); else { lint j=stack.top();stack.pop(); a.at(i)=j; a.at(j)=i; } } for(lint x:a){ std::cout<<x+1<<'\n'; } }