結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
chacoder1
|
| 提出日時 | 2020-11-23 13:33:26 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 363 bytes |
| 記録 | |
| コンパイル時間 | 2,211 ms |
| コンパイル使用メモリ | 214,656 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-15 08:39:43 |
| 合計ジャッジ時間 | 8,289 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
chacoder1