結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-06-13 16:25:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 461 bytes |
| コンパイル時間 | 1,456 ms |
| コンパイル使用メモリ | 171,088 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 07:50:02 |
| 合計ジャッジ時間 | 2,101 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep2(i, a, n) for(ll i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
int main(){
cin.tie(nullptr);ios_base::sync_with_stdio(false);
ll n,k;cin>>n>>k;
string s;cin>>s;
ll table[n],left;
stack<ll> st;
rep(i,n){
if(s[i]=='('){
st.push(i);
}else{
left=st.top();st.pop();
table[left]=i;
table[i]=left;
}
}
cout<<table[k-1]+1<<endl;
}
mag