結果
| 問題 | No.592 括弧の対応 (2) |
| コンテスト | |
| ユーザー |
e869120
|
| 提出日時 | 2017-11-10 22:23:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 632 bytes |
| コンパイル時間 | 622 ms |
| コンパイル使用メモリ | 82,644 KB |
| 実行使用メモリ | 10,404 KB |
| 最終ジャッジ日時 | 2024-11-24 12:10:37 |
| 合計ジャッジ時間 | 13,346 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 2 |
ソースコード
#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;
}
e869120