結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-26 11:16:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 423 bytes |
| コンパイル時間 | 1,675 ms |
| コンパイル使用メモリ | 167,916 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-16 05:03:55 |
| 合計ジャッジ時間 | 3,004 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
const ll INF = 1e10;
const int MOD = 1000000007;
int main(){
string S;
cin >> S;
int n = S.size();
ll w = 0;
ll ans = 0;
for(int i=n-1;i>=0;i--){
if(S[i] == 'w') w ++;
if(S[i] == 'c') ans += w*(w-1)/2;
}
cout << ans << endl;
return 0;
}