結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
|
提出日時 | 2020-07-19 23:32:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,759 ms / 2,000 ms |
コード長 | 391 bytes |
コンパイル時間 | 1,778 ms |
コンパイル使用メモリ | 168,748 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 18:18:26 |
合計ジャッジ時間 | 7,111 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i=0; i<(n); i++)typedef long long ll;int main(){string s; cin>>s;int n=s.size();int ck=0;ll ans=0;for(ll i=0; i<n-2; i++){ll cnt=0;if(s[i]=='c'){for(ll j=n-1; j>=i; j--){if(s[j]=='w') cnt++;}if(i==0&&cnt==0){cout<<0<<endl; return 0;}}ans+=(cnt*(cnt-1))/2;}cout<<ans<<endl;}