結果

問題 No.345 最小チワワ問題
ユーザー Kaz_nl
提出日時 2017-08-23 22:13:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 474 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 57,564 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 13:34:50
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int t, cnt;

int main() {
  string s;
  int ans = 101;
  cin >> s;
  for (auto& e : s) {
    if (e == 'c') {
      t = 1;
      cnt = 1;
    } else if (e == 'w') {
      if (t == 1) {
        t++;
        cnt++;
      } else if (t == 2) {
        cnt++;
        t = 0;
        ans = min(ans, cnt);
      }
    } else {
      cnt++;
    }
  }
  if (ans == 101) ans = -1;
  cout << ans << endl;
}
0