結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-20 03:40:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 536 bytes |
| コンパイル時間 | 1,997 ms |
| コンパイル使用メモリ | 192,852 KB |
| 最終ジャッジ日時 | 2025-01-15 11:51:55 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
// constexpr ll mod=1e9+7;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
string s; cin >> s;
reverse(s.begin(), s.end());
ll res=0;
ll w=0;
for(char c:s){
if(c=='w')w++;
if(c=='c'){
res+=w*(w-1)/2;
}
}
cout << res << endl;
}