結果
| 問題 | No.22 括弧の対応 |
| コンテスト | |
| ユーザー |
zaichu
|
| 提出日時 | 2015-12-28 21:52:55 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 560 bytes |
| 記録 | |
| コンパイル時間 | 934 ms |
| コンパイル使用メモリ | 175,524 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-16 16:22:44 |
| 合計ジャッジ時間 | 1,859 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k;
string str;
cin >> n >> k >> str;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
if(str[j] == ' ') continue;
else if(str[i] == '(' and str[j] == ')'){
str[i] = ' '; str[j] = ' ';
// cout << i+1 << " " << j+1 << endl;
// cout << str << endl;
if(i+1 == k){
cout << j + 1 << endl;
return 0;
}
if(j + 1 == k){
cout << i + 1 << endl;
return 0;
}
while(str[i] != '(') i--;
}
else i = j;
}
}
return 0;
}
zaichu