結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
|
提出日時 | 2016-02-26 22:39:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 408 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 57,460 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 22:04:07 |
合計ジャッジ時間 | 1,358 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string s, t; cin >> s; long long nw = 0; int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == 'w') { nw++; } } long long ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'w') { nw--; } else if (s[i] == 'c') { ans += nw * (nw - 1) / 2; } } cout << ans << endl; return 0; }