結果

問題 No.345 最小チワワ問題
ユーザー Noiri
提出日時 2017-12-09 01:41:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 55,260 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 22:16:33
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:9: warning: ‘count’ may be used uninitialized [-Wmaybe-uninitialized]
   10 |         if(count == 2) break;
      |         ^~

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main(){
    string cww; cin >> cww;
    int len = cww.size();
    int count;
    for(int i = 0; i < len-2; i++){
        if(count == 2) break;
        count = 0;
        if(cww[i] == 'c'){
            for(int j = i+1; j < len-1; j++){
                if(cww[j] == 'w'){
                    count += 1;
                    if(count == 2){
                        cout << j - i + 1 << endl;
                        break;
                    }
                }
            }
        }
    }
    if(count != 2) cout << -1 << endl;
    return 0;
}
0