結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
ひばち
|
| 提出日時 | 2020-01-15 12:59:59 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 755 bytes |
| 記録 | |
| コンパイル時間 | 1,235 ms |
| コンパイル使用メモリ | 181,480 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-06 04:44:28 |
| 合計ジャッジ時間 | 3,123 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,m) for(int i=(int)(m)-1;i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end
void solve(){
string s;
cin>>s;
vector<int> ct(s.size()+1);
rrep(i,s.size())ct[i]=ct[i+1]+(s[i]=='w');
ll res=0;
rep(i,s.size())
if(s[i]=='c')res+=(ll)ct[i]*(ct[i]-1)/2;
cout<<res<<endl;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
ひばち