結果

問題 No.22 括弧の対応
ユーザー skskpandaskskpanda
提出日時 2019-11-05 23:31:39
言語 C++11
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 483 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 55,636 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-09-15 00:16:33
合計ジャッジ時間 19,856 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

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]=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