結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2020-03-25 16:38:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 309 bytes |
コンパイル時間 | 1,778 ms |
コンパイル使用メモリ | 171,912 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:48:57 |
合計ジャッジ時間 | 2,169 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; signed main(){ int n,k;cin>>n>>k; string s;cin>>s; vector<int> ans(n); stack<int> sta; for(int i=0;i<n;i++){ if(s[i]=='(')sta.push(i); else{ ans[i]=sta.top(); ans[sta.top()]=i; sta.pop(); } } cout<<ans[k-1]+1<<endl; }