結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-12 02:02:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 1,605 ms |
| コンパイル使用メモリ | 167,712 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-21 07:25:23 |
| 合計ジャッジ時間 | 3,022 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long
int main() {
string s;
cin >> s;
reverse(s.begin(), s.end());
llong result = 0;
int ccnt = 0;
int wcnt = 0;
for(char c: s) {
if(c == 'w') {
wcnt += 1;
} else if(c == 'c') {
if(wcnt>=2) {
result += (llong)wcnt * (wcnt-1) / 2;
}
}
}
cout << result << "\n";
}