結果

問題 No.346 チワワ数え上げ問題
ユーザー kuisiba
提出日時 2016-11-11 11:53:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 387 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 56,944 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 08:07:01
合計ジャッジ時間 1,229 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <string>

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  int ans = 0;
  int w = 0;
  for (int i = s.size() - 1; 0 <= i; i--) {
    if (s.at(i) == 'w') {
      w++;
      continue;
    }
    if (s.at(i) == 'c') {
      ans += w * (w - 1) / 2;
    }
  }
  cout << ans << endl;
}

0