結果

問題 No.305 鍵(2)
ユーザー bal4ubal4u
提出日時 2019-04-14 20:26:28
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 28,044 KB
実行使用メモリ 24,372 KB
平均クエリ数 44.08
最終ジャッジ日時 2023-09-24 02:13:29
合計ジャッジ時間 1,785 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,556 KB
testcase_01 AC 26 ms
24,240 KB
testcase_02 AC 26 ms
23,364 KB
testcase_03 AC 26 ms
24,012 KB
testcase_04 AC 26 ms
24,000 KB
testcase_05 AC 27 ms
23,424 KB
testcase_06 AC 23 ms
24,048 KB
testcase_07 AC 26 ms
23,412 KB
testcase_08 AC 26 ms
24,000 KB
testcase_09 AC 25 ms
23,640 KB
testcase_10 AC 26 ms
24,372 KB
testcase_11 AC 26 ms
24,252 KB
testcase_12 AC 26 ms
23,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.305 鍵(2)
// 2019.4.14 bal4u

#include <stdio.h>

#define pc(c) putchar(c)
void outs(char *s) {
	while (*s) pc(*s++);
	pc('\n');
	fflush(stdout);
}

char base[] = "0000000000";
int val;

int try(int id)
{
	int i, k;
	char s[15];
	for (i = '1'; i <= '9'; i++) {
		base[id] = i;
		outs(base);
		scanf("%d%s", &k, s);
		if (k == 10) return 1;
		if (k != val) {
			if (k < val) base[id] = i - 1;
			else val = k;
			break;
		}
	}
	return 0;
}

int main()
{
	int i;
	char s[15];

	outs(base);
	scanf("%d%s", &val, s);
	if (val == 10) return 0;
	for (i = 0; i < 10; i++) {
		if (try(i)) break;
	}
	return 0;
}
0