結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2019-10-23 21:52:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 292 bytes |
コンパイル時間 | 688 ms |
コンパイル使用メモリ | 65,044 KB |
最終ジャッジ日時 | 2025-01-08 00:51:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }