結果

問題 No.345 最小チワワ問題
ユーザー hachidesyuhachidesyu
提出日時 2020-07-06 18:31:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 170,176 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:08:25
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,348 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;

    //一番右のcを探す
    int last_c = s.size();
    int loop = 0;
    int size = s.size();
    int res[100] = {0};

    while(1){
        int count_w = 0;
        for(int i = 0; i < size; i++){
             if(s[i] == 'c'){
                last_c = i;
            }
        }

        size = last_c;
        //一番右のcからwが二つ目まで探す
        for(int i = last_c; i < s.size(); i++){
            if(s[i] == 'w'){
                count_w++;
            }
            if(count_w == 2){
                res[i] = i-last_c+1;
            }
        }

        loop++;
        if(loop > 100) break;
    }
    
   sort(res, res + 100, greater<>());
   if(res[0] < 3) cout << -1 << endl;
   else cout << res[0] << endl; 
}
0