結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
|
提出日時 | 2016-04-13 01:33:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 417 bytes |
コンパイル時間 | 461 ms |
コンパイル使用メモリ | 56,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 06:39:33 |
合計ジャッジ時間 | 1,232 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 2 |
ソースコード
#include <iostream> #include <string> using namespace std; int main() { int w_cnt=0, temp; long long int sum; string str; cin >> str; for(int i=0;i<str.length();++i)if(str[i]=='w')++w_cnt; temp = sum = 0; for(int i=0;i<str.length();++i){ if(str[i] == 'w'){ ++temp; }else if(str[i] == 'c'){ w_cnt -= temp; sum += w_cnt * (w_cnt - 1) / 2; temp = 0; } } cout << sum << endl; return 0; }