結果

問題 No.345 最小チワワ問題
ユーザー fumi6328
提出日時 2018-08-27 12:27:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 55,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 04:06:49
合計ジャッジ時間 1,419 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    int ans = 0,flag = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'c'){
            for(int j = i; j < s.length(); j++){
                ans++;
                if(s[j] == 'w') flag++;
                if(flag == 2){
                    cout << ans << endl;
                    return 0;
                }
                if(j == s.length() - 1){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
}
0