結果
| 問題 |
No.22 括弧の対応
|
| コンテスト | |
| ユーザー |
zaichu
|
| 提出日時 | 2015-12-28 21:50:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 210 ms / 5,000 ms |
| コード長 | 560 bytes |
| コンパイル時間 | 1,301 ms |
| コンパイル使用メモリ | 158,580 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 14:48:16 |
| 合計ジャッジ時間 | 2,969 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 break;
}
}
return 0;
}
zaichu