結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2017-05-07 22:46:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 321 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 166,544 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 14:53:14 |
合計ジャッジ時間 | 2,448 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #define REP(i,n,N) for(int i=(n);i<(int)N;i++) #define p(s) cout<<(s)<<endl typedef long long ll; using namespace std; int main(){ string s; cin>>s; ll w=0; ll ans=0; for(int i=s.size()-1;i>=0;i--){ if(s[i]=='w') w++; else if(s[i]=='c') { ans+=w*(w-1)/2; } } p(ans); return 0; }