結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
ふーらくたる
|
| 提出日時 | 2016-07-06 09:40:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 442 bytes |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 58,676 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-12 20:25:36 |
| 合計ジャッジ時間 | 1,322 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
string S;
void Solve() {
ll ans = 0, w_cnt = 0;
reverse(S.begin(), S.end());
for (int i = 0; i < S.size(); i++) {
if (S[i] == 'c') {
ans += w_cnt * (w_cnt - 1) / 2;
} else if (S[i] == 'w') {
w_cnt++;
}
}
cout << ans << endl;
}
int main() {
cin >> S;
Solve();
return 0;
}
ふーらくたる