結果
問題 | No.592 括弧の対応 (2) |
ユーザー | e869120 |
提出日時 | 2017-11-10 22:23:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 632 bytes |
コンパイル時間 | 854 ms |
コンパイル使用メモリ | 82,612 KB |
実行使用メモリ | 10,528 KB |
最終ジャッジ日時 | 2024-05-03 12:16:39 |
合計ジャッジ時間 | 7,169 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | TLE | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
ソースコード
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cmath> #include<queue> #include<functional> #include<map> using namespace std; string S; int n; int main() { cin >> n >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '(') { int depth = 0; for (int j = i; j < S.size(); j++) { if (S[j] == '(')depth++; else depth--; if (depth == 0) { cout << j + 1 << endl; break; } } } if (S[i] == ')') { int depth = 0; for (int j = i; j >= 0; j--) { if (S[j] == '(')depth++; else depth--; if (depth == 0) { cout << j + 1 << endl; break; } } } } return 0; }