結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2020-01-15 12:59:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 1,694 ms |
コンパイル使用メモリ | 161,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-02 16:35:32 |
合計ジャッジ時間 | 3,192 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 endvoid 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;}