結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             f843nmfwisfeuw
                         | 
                    
| 提出日時 | 2020-06-12 19:24:05 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 927 bytes | 
| コンパイル時間 | 848 ms | 
| コンパイル使用メモリ | 91,152 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-24 04:08:42 | 
| 合計ジャッジ時間 | 2,035 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 WA * 14 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool found = false;
    int tmpC = 0;
    int ans = 0;
    for (int i = 0; i < S.size() - 2; ++i) {
        if (S[i] == 'c') {
            tmpC = i;
            int cnt = 0;
            for (int j = i + 1; j < S.size(); ++j) {
                if (S[j] == 'w') {
                    cnt += 1;
                    if (cnt == 2) {
                        found = true;
                        ans = j - tmpC + 1;
                        break;
                    }
                }
            }
            break;
        }
    }
    if (found) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}
            
            
            
        
            
f843nmfwisfeuw