結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Yut176
                         | 
                    
| 提出日時 | 2016-10-07 22:00:32 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 558 bytes | 
| コンパイル時間 | 762 ms | 
| コンパイル使用メモリ | 73,196 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-21 19:55:45 | 
| 合計ジャッジ時間 | 1,591 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 6 | 
ソースコード
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  bool fl = false;
  int w = 0;
  for(int i=0; i<s.size(); i++){
    if( s[i] == 'c' ) fl = true;
    if( s[i] == 'c' && w == 0 ) cnt = 0;
    if( fl ) cnt++;
    if( fl && s[i] == 'w' ) w++;
    if( w == 2 ) break;
  }
  if( cnt != 0 && w == 2 ) cout << cnt << endl;
  else cout << -1 << endl;
  return 0;
}
            
            
            
        
            
Yut176