結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2020-11-23 13:33:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 363 bytes |
コンパイル時間 | 3,257 ms |
コンパイル使用メモリ | 199,048 KB |
最終ジャッジ日時 | 2025-01-16 05:05:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N,K; cin>>N>>K; int T[N]; string S; cin>>S; int len=S.length(); stack<int>sta; for(int i=0;i<len;i++){ if(S.at(i)=='('){ sta.push(i); } if(S.at(i)==')'){ T[i]=sta.top(); T[sta.top()]=i; sta.pop(); } } cout<<T[K-1]+1<<endl; return 0; }