結果

問題 No.346 チワワ数え上げ問題
ユーザー koturn
提出日時 2016-02-27 17:19:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 57,416 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 11:41:45
合計ジャッジ時間 1,401 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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


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

  std::string s;
  std::cin >> s;
  int cnt = 0, wcnt = 0;
  for (std::string::size_type i = s.length() - 1; i != static_cast<std::string::size_type>(-1); i--) {
    switch (s[i]) {
      case 'c':
        cnt += wcnt * (wcnt - 1) / 2;
        break;
      case 'w':
        wcnt++;
        break;
    }
  }
  std::cout << cnt << std::endl;

  return EXIT_SUCCESS;
}
0