結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-02-27 21:53:15 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 460 bytes | 
| コンパイル時間 | 479 ms | 
| コンパイル使用メモリ | 56,480 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-24 11:48:53 | 
| 合計ジャッジ時間 | 1,559 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 WA * 15 | 
ソースコード
#include <iostream>
int main() {
    std::string s;
    int max = 0, flag = 0, cnt = 0;
    std::cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (!flag && s[i] == 'c') flag = 1;
        else if (flag && s[i] == 'w') flag += 1;
        if (flag) cnt += 1;
        if (flag == 3) {
            max = max < cnt ? cnt : max;
            flag = 0;
            cnt = 0;
        }
    }
    std::cout << (max ? max : -1) << std::endl;
    return 0;
}