結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2021-07-16 20:03:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 1,333 ms |
コンパイル使用メモリ | 166,316 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 06:40:13 |
合計ジャッジ時間 | 1,959 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; using ll=long long; using Graph=vector<vector<int>>; #define MAX 1000000 #define MOD 1000000007 //#define MOD 998244353 #define INF 1000000000 //#define INF 1000000000000000000 int main(){ int N,K; string S; cin>>N>>K>>S; int i=K-1; int x=0; if(S[i]=='('){ while(true){ if(S[i]=='('){ x++; }else{ x--; } if(x==0){ cout<<i+1<<endl; return 0; } i++; } }else{ while(true){ if(S[i]==')'){ x++; }else{ x--; } if(x==0){ cout<<i+1<<endl; return 0; } i--; } } }