結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2016-03-11 21:12:04 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| + 958µs | |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 90,264 KB |
| 実行使用メモリ | 9,744 KB |
| 最終ジャッジ日時 | 2026-09-03 15:32:22 |
| 合計ジャッジ時間 | 3,210 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
string s;
int main(){
while(cin >> s){
int n = s.size();
reverse(begin(s), end(s));
int cntw = 0;
long long ans = 0;
rep(i,n){
if(s[i] == 'w'){
cntw++;
} else if(s[i] == 'c'){
ans += 1LL*cntw*(cntw-1)/2;
}
}
cout << ans << endl;
}
}
tubo28