結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2018-07-25 14:54:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 363 bytes |
コンパイル時間 | 1,638 ms |
コンパイル使用メモリ | 172,800 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:32:50 |
合計ジャッジ時間 | 2,257 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ Int n,k; cin>>n>>k;k--; string s; cin>>s; stack<Int> st; vector<Int> dp(n); for(Int i=0;i<n;i++){ if(s[i]=='(') st.push(i); else{ Int x=st.top();st.pop(); dp[x]=i; dp[i]=x; } } cout<<dp[k]+1<<endl; return 0; }