結果

問題 No.345 最小チワワ問題
ユーザー Eclair1015
提出日時 2018-07-10 20:31:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 60,232 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 19:26:49
合計ジャッジ時間 1,604 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include<string>

using namespace std;
int main(){
	string s;
	bool flag = false;
	int cnt = 0,a=0,co=0;
	int minv=-1;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'c') {
			flag = true;
		}

		if (flag) {
			cnt++;
			if (s[i] == 'w') {
				a++;
				if (a == 2) {
					flag = false;
					co++;
					if (co == 1) {
						minv = cnt;
					}else{
						minv = min(minv, cnt);
					}
				}
			}
		}
	}
	cout << minv << endl;
}

0