結果
問題 |
No.22 括弧の対応
|
ユーザー |
![]() |
提出日時 | 2016-09-18 19:55:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 496 bytes |
コンパイル時間 | 1,284 ms |
コンパイル使用メモリ | 54,504 KB |
実行使用メモリ | 13,632 KB |
最終ジャッジ日時 | 2024-11-17 09:02:16 |
合計ジャッジ時間 | 93,799 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 5 TLE * 13 |
ソースコード
#include <iostream> #define REP(i, a, b) for (int i = a; i < b; i++) #define REP2(i, a, b) for (int i = a; i <= b; i++) using namespace std; int main () { int N, K; cin >> N >> K; char str[10000+1]; REP2 (i, 1, N) cin >> str[i]; int cnt = 0; int n = K; for (;;) { if (str[n] == '(') { cnt++; } else { // K番目の括弧が')'の時 cnt--; } if (cnt == 0) { cout << n << endl; return 0; } if (n == N) n = 1; } return 0; }