結果

問題 No.22 括弧の対応
ユーザー skskpandaskskpanda
提出日時 2019-11-05 23:29:36
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 495 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 51,336 KB
実行使用メモリ 5,188 KB
最終ジャッジ日時 2023-10-13 02:32:02
合計ジャッジ時間 15,347 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,028 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1,368 ms
4,352 KB
testcase_04 AC 135 ms
4,352 KB
testcase_05 AC 100 ms
4,348 KB
testcase_06 AC 1,940 ms
4,352 KB
testcase_07 AC 111 ms
4,352 KB
testcase_08 AC 8 ms
4,352 KB
testcase_09 AC 2,327 ms
4,348 KB
testcase_10 AC 29 ms
4,352 KB
testcase_11 AC 97 ms
4,352 KB
testcase_12 AC 908 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

int main(void){
  int n;
  int k;
  string c;

  int i;
  int j;

  cin>>n>>k;
  cin>>c;

  i=0;
  j=i+1;

  while(1){
    while(c[j]=='X'){
      j++;
    }
    if(c[j]==')'){
      c[i]='X';
      c[j]='X';
      if(i==k-1||j==k-1){
        break;
      }else{
        i=0;
        j=i+1;
      }
    }else{
      i++;
      j=i+1;
    }
  }

  cout<<((i==k-1)?j+1:i+1)<<endl;

  return 0;
}
0