結果

問題 No.345 最小チワワ問題
ユーザー tenkyu9
提出日時 2018-01-22 02:00:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 68,980 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 22:03:25
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  string s;
  int ans;
  cin >> s;

  for(int i=0; i<s.size(); i++){
    if(s[i]=='c'){
      ans=1;
      for(int j=i+1; j<s.size(); j++){
        ans++;
        if(s[j]=='w'){
          for(int k=j+1; k<s.size(); k++){
            ans++;
            if(s[k]=='w'){
              cout << ans << endl;
              return 0;
            } else if(s[k]=='c'){
              break;
            }
          }
        } else if(s[j]=='c'){
          break;
        }
      }
    }
  }

  cout << -1 << endl;

  return 0;
}
0