結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-08 13:17:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 427 bytes |
| コンパイル時間 | 1,345 ms |
| コンパイル使用メモリ | 158,300 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:24:38 |
| 合計ジャッジ時間 | 2,320 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
int main(){
//階乗を前計算
string S;
cin >> S;
ll ans = 0;
//後ろから選んだほうが早い..?
ll count = 0;
for(ll i = S.length(); i >= 0; i--){
if(S[i] == 'c'){
ans += count * (count - 1) / 2;
}else if(S[i] == 'w'){
count++;
}
}
cout << ans << endl;
}