結果

問題 No.345 最小チワワ問題
ユーザー RCCW
提出日時 2017-02-07 23:49:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 158,432 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 15:35:10
合計ジャッジ時間 2,839 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
	string s;
	cin >> s;
	bool flag = 0;
	int count = 0;
	int now,ans=5000000,tmp=-1;
	for (int i = 0; i < s.length(); ++i) {
		count=0;
		if (s[i] == 'c') {
			now=i;
			while (i < s.length()) {
				i++;
				if(s[i]=='w'&&count==0){
					count++;
				}else if(s[i]=='w'&&count==1){
					tmp=i-now+1;
					ans=min(ans,tmp);
				}
			}
		}
	}
	cout<<((ans!=5000000)?ans:-1)<<endl;
}
0