結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2020-07-08 00:28:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 370 bytes |
コンパイル時間 | 1,985 ms |
コンパイル使用メモリ | 193,448 KB |
最終ジャッジ日時 | 2025-01-11 16:45:06 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; int64_t w = 0; for (auto s : S) { if (s == 'w') w++; } int64_t res = 0; for (auto s : S) { if (s == 'c') { res += w * (w - 1) / 2; } else if (s == 'w') { w--; } } cout << res << '\n'; return 0; }