結果

問題 No.345 最小チワワ問題
ユーザー koturn
提出日時 2016-02-27 00:34:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 55,888 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 10:46:00
合計ジャッジ時間 1,415 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <array>
#include <iostream>
#include <string>


int
main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s;
  std::cin >> s;
  std::array<std::string::size_type, 3> ps{0, 0, 0};
  std::string::size_type pos = -1;
  int idx = 0;
  for (const auto& c : {'c', 'w', 'w'}) {
    if ((pos = s.find(c, pos + 1)) == std::string::npos) {
      std::cout << -1 << std::endl;
      return EXIT_SUCCESS;
    } else {
      ps[idx++] = pos;
    }
  }
  std::cout << (ps[2] - ps[0] + 1) << std::endl;

  return EXIT_SUCCESS;
}
0