結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hamray
                         | 
                    
| 提出日時 | 2017-11-14 00:46:51 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 693 bytes | 
| コンパイル時間 | 652 ms | 
| コンパイル使用メモリ | 72,212 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 00:34:39 | 
| 合計ジャッジ時間 | 1,454 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 21 WA * 8 | 
ソースコード
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
int main(){
    string S; cin >> S;
    int minV = S.size() + 1;
    
    for(int i=0; i<S.size(); i++){
        if(S[i] == 'c'){
            int cnt = 0;
            for(int j = i+1; j<S.size(); j++){
                if(S[j] == 'w'){
                    cnt++;
                    if(cnt == 2){
                        minV = min(minV, j - i + 1);
                        break;
                    }
                }
                }
            }
        }
    if(minV == S.size() - 1) minV = -1;
    cout << minV << endl;
    return 0;
    }
            
            
            
        
            
hamray