結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
Kura
|
| 提出日時 | 2019-07-11 08:17:29 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| + 286µs | |
| コード長 | 419 bytes |
| 記録 | |
| コンパイル時間 | 822 ms |
| コンパイル使用メモリ | 174,236 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-19 18:33:39 |
| 合計ジャッジ時間 | 2,009 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;string s;
cin>>n>>m>>s;
int c=0;
if(s[m-1]=='('){
for(int i=m;i<n;i++){
if(s[i]=='(')c++;
else c--;
if(c==-1){
cout<<i+1<<endl;
return 0;
}
}
}else{
for(int i=m-2;i>=0;i--){
if(s[i]=='(')c++;
else c--;
if(c==1){
cout<<i+1<<endl;
return 0;
}
}
}
}
Kura