結果
問題 | No.22 括弧の対応 |
ユーザー |
|
提出日時 | 2016-04-15 02:13:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 350 bytes |
コンパイル時間 | 451 ms |
コンパイル使用メモリ | 56,796 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:11:30 |
合計ジャッジ時間 | 1,331 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <string> using namespace std; int main() { int n, k, cnt; string s; cin >> n >> k >> s; if(s[k-1] == '('){ cnt = 1; while(cnt){ ++k; if(s[k-1] == '(')++cnt; else --cnt; } }else{ cnt = 1; while(cnt){ --k; if(s[k-1] == ')')++cnt; else --cnt; } } cout << k << endl; return 0; }