結果

問題 No.345 最小チワワ問題
ユーザー AQUA16573837AQUA16573837
提出日時 2018-03-12 02:10:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 42,956 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 04:25:54
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

int main() {
	char s[101] = { 0 };
	scanf("%s", s);
	int mins = 1000;
	deque<int> c, w;
	for (int i = 0; s[i] != 0; i++) {
		if (s[i] == 'c')
			c.emplace_back(i);
		if (s[i] == 'w') {
			if (2 <= w.size())
				w.pop_front();
			w.emplace_back(i);

			while (2 <= c.size() && c[1] < w[0])
				c.pop_front();
			if (1 <= c.size() && 2 <= w.size() && c[0] < w[0])
				mins = min(mins, w[1] - c[0] + 1);
		}
	}
	printf("%d\n", mins != 1000 ? mins : -1);
}
0