結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-30 19:13:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 349 bytes |
| コンパイル時間 | 2,033 ms |
| コンパイル使用メモリ | 195,300 KB |
| 最終ジャッジ日時 | 2025-01-12 08:12:09 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0),ios::sync_with_stdio(false);
string s; cin>>s;
int n=s.size();
vector<int>cnt(n+1,0);
for(int i=n-1;i>=0;--i)cnt.at(i)=cnt.at(i+1)+(s.at(i)=='w');
int64_t ans=0;
for(int i=0;i<n;++i){
if(s.at(i)!='c')continue;
ans+=1L*cnt.at(i)*(cnt.at(i)-1)/2;
}
cout<<ans<<"\n"s;
}