結果
問題 |
No.22 括弧の対応
|
ユーザー |
|
提出日時 | 2016-07-07 09:36:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 646 ms |
コンパイル使用メモリ | 63,360 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 07:14:01 |
合計ジャッジ時間 | 1,324 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { int n, k; cin >> n >> k; string s; cin >> s; int position = k; int direction = ((s[position - 1] == '(') ? 1 : -1); int depth = direction; do { position += direction; depth += ((s[position - 1] == '(') ? 1 : -1); } while (depth != 0); cout << position << endl; return 0; }