結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
Series_205
|
| 提出日時 | 2019-10-23 21:52:31 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 292 bytes |
| 記録 | |
| コンパイル時間 | 412 ms |
| コンパイル使用メモリ | 80,128 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-08 01:59:59 |
| 合計ジャッジ時間 | 1,721 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int n,k;
string s;
int main(){
cin>>n>>k>>s;
int x=1,num=1,t;
if(s[k-1]==')')x=-1;
t=k-1+x;
while(num){
if(s[k-1]==s[t])num++;
else num--;
t+=x;
}
cout<<t-x+1<<endl;
return 0;
}
Series_205