結果

問題 No.345 最小チワワ問題
ユーザー ommadawn46ommadawn46
提出日時 2016-02-26 23:03:55
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 592 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 59,564 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 05:50:47
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 RE -
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 2 ms
4,348 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 2 ms
4,348 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <list>

using namespace std;

int main(void){
  string s;
  cin >> s;

  int min = -1;
  list<int*> c;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'c'){
      int *ci = new int[2];
      ci[0] = i; ci[1] = 0;
      c.push_back(ci);
    }else if(s[i] == 'w'){
      list<int*>::iterator it = c.begin();
      while( it != c.end() ){
        int *ci = *it;
        if(++ci[1] >= 2){
          min = i - ci[0] + 1 < min || min < 0 ? i - ci[0] + 1 : min;
          c.pop_front();
        }
		    ++it;
      }
    }
	}

  cout << min << endl;
  return 0;
}
0