結果

問題 No.345 最小チワワ問題
ユーザー mizuyoukannKBmizuyoukannKB
提出日時 2016-04-03 11:11:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 65,152 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:48:50
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstring>
#include <iostream>

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	int wCnt;				//ワーク
	char str[100] = { 0 };	//文字列
	char *now, *search;		//現在位置

	int work = 0;
	int ans = 100;

	//入力
	cin >> str;

	int loop = strlen(str);

	search = str;

	//文字捜索開始
	while(loop)
	{
		//Cを見つける
		if(*search == 'c')
		{
			//Cの位置を記憶
			now = search;
			++work;

			//wカウント2
			wCnt = 2;

			//文字カウントスタート
			while(wCnt)
			{
				//現在位置カウンタ 進め
				++now;

				//文字数も進める
				++work;

				//wを見つけたら
				if(*now == 'w')
				{
					//カウントダウン
					--wCnt;
				}

				//文字が無くなったら 抜ける
				if(!(*now))
				{
					work = 100;
					break;
				}
			}

			//文字カウント最小値更新
			if(work < ans)
			{
				ans = work;
			}

			work = 0;
		}

		++search;
		--loop;
	}

	cout << ((ans == 100) ? (-1) : (ans)) << endl;

	return 0;
}
0