結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
kyuna
|
| 提出日時 | 2019-08-20 19:09:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 397 bytes |
| 記録 | |
| コンパイル時間 | 681 ms |
| コンパイル使用メモリ | 70,164 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 12:51:48 |
| 合計ジャッジ時間 | 1,565 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
string s; cin >> s;
reverse(s.begin(), s.end());
int cnt_w = 0;
long long ans = 0;
for (char c: s) {
if (c == 'c') {
ans += 1LL * cnt_w * (cnt_w - 1) / 2;
} else if (c == 'w') {
cnt_w++;
}
}
cout << ans << endl;
return 0;
}
kyuna