結果

問題 No.345 最小チワワ問題
ユーザー takubokudoritakubokudori
提出日時 2017-08-29 22:51:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,178 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 89,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 03:01:42
合計ジャッジ時間 1,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#define N 1000
#define re(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fe(i,n,f) for_each(i,n,f)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(void){
	string s;
	int n=0;
	int m=999;
	int state=0;
	cin>>s;

	re(i,s.size()){
		switch (state) {
			case 0:
				if(s[i]=='c'){state=1;n=1;}
				break;
			case 1:
				n++;
				if(s[i]=='w')state=2;
				break;
			case 2:
				n++;
				if(s[i]=='w'){
					state=0;
					m=min(m,n);
				}
				break;
		}
	}
	for(int i=s.size()-1;i>=0;i--){
		switch (state) {
			case 0:
				if(s[i]=='w'){state=1;n=1;}
				break;
			case 1:
				n++;
				if(s[i]=='w')state=2;
				break;
			case 2:
				n++;
				if(s[i]=='c'){
					state=0;
					m=min(m,n);
				}
				break;
		}
	}


	cout<<(m!=999?m:-1)<<endl;
	return 0;
}
0