結果

問題 No.345 最小チワワ問題
ユーザー キョウチク
提出日時 2019-03-11 14:17:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 55,220 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-23 15:31:08
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	int cwwFlag = false;

	int cwwCounter[2] = { 100,0 };

	cin >> S;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'c'&&cwwFlag == 0) {
			cwwFlag++;
		}
		if (cwwFlag > 0) {
			cwwCounter[1]++;
			if(S[i] == 'w') cwwFlag++;
			if (cwwFlag == 3) {
				if (cwwCounter[1] < cwwCounter[0]) {
					cwwCounter[0] = cwwCounter[1];
				}
				cwwCounter[1] = 0;
				cwwFlag = 0;
			}
		}
	}
	if (cwwCounter[0] == 100) cwwCounter[0] = -1;
	cout << cwwCounter[0] << endl;

	return 0;
}
0