結果

問題 No.1149 色塗りゲーム
ユーザー anagohirameanagohirame
提出日時 2020-08-07 23:15:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 92,924 KB
平均クエリ数 19.06
最終ジャッジ日時 2023-09-24 05:01:00
合計ジャッジ時間 10,545 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
87,776 KB
testcase_01 AC 113 ms
87,628 KB
testcase_02 AC 113 ms
86,940 KB
testcase_03 AC 112 ms
87,312 KB
testcase_04 AC 114 ms
87,560 KB
testcase_05 AC 113 ms
87,772 KB
testcase_06 AC 112 ms
87,436 KB
testcase_07 AC 116 ms
87,116 KB
testcase_08 AC 113 ms
86,968 KB
testcase_09 AC 114 ms
87,832 KB
testcase_10 AC 122 ms
91,796 KB
testcase_11 AC 116 ms
87,140 KB
testcase_12 AC 116 ms
87,032 KB
testcase_13 AC 116 ms
87,416 KB
testcase_14 AC 122 ms
92,104 KB
testcase_15 AC 123 ms
91,808 KB
testcase_16 AC 116 ms
87,416 KB
testcase_17 AC 123 ms
92,160 KB
testcase_18 AC 121 ms
91,596 KB
testcase_19 AC 123 ms
92,172 KB
testcase_20 AC 123 ms
91,312 KB
testcase_21 AC 123 ms
92,040 KB
testcase_22 AC 125 ms
91,748 KB
testcase_23 AC 128 ms
91,812 KB
testcase_24 AC 126 ms
92,176 KB
testcase_25 AC 126 ms
92,056 KB
testcase_26 AC 122 ms
91,972 KB
testcase_27 AC 128 ms
92,416 KB
testcase_28 AC 127 ms
91,692 KB
testcase_29 AC 135 ms
92,072 KB
testcase_30 AC 175 ms
92,548 KB
testcase_31 AC 169 ms
92,004 KB
testcase_32 AC 173 ms
92,924 KB
testcase_33 AC 175 ms
92,252 KB
testcase_34 AC 181 ms
92,552 KB
testcase_35 AC 177 ms
92,404 KB
testcase_36 AC 180 ms
92,104 KB
testcase_37 AC 181 ms
92,720 KB
testcase_38 AC 185 ms
92,496 KB
testcase_39 AC 186 ms
92,460 KB
testcase_40 AC 188 ms
92,656 KB
testcase_41 AC 193 ms
92,648 KB
testcase_42 AC 192 ms
92,464 KB
testcase_43 AC 196 ms
92,680 KB
testcase_44 AC 199 ms
92,620 KB
testcase_45 AC 192 ms
92,668 KB
testcase_46 AC 201 ms
92,580 KB
testcase_47 AC 199 ms
92,468 KB
testcase_48 AC 202 ms
92,372 KB
testcase_49 AC 207 ms
92,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import exit
n = int(input())
grundy = [0 for _ in range(n+1)]
grundy[1] = 1
#grundy[2] = 2
for i in range(2, n+1):
	g = set()
	for j in range(i):
		g.add(grundy[j] ^ grundy[i-j-1])
		if j < i-1:
			g.add(grundy[j] ^ grundy[i-j-2])
	x = 0
	while x in g:
		x += 1
	grundy[i] = x
#print(grundy)

def calc(b):
	g = 0
	tmp = 0
	for i in range(n+1):
		if b[i]:
			tmp += 1
		else:
			g ^= grundy[tmp]
			tmp = 0
	#print(b, g)
	#print("#####")
	return g

def cop(b, k, x):
	res = [True for _ in range(n+1)]
	res[n] = False
	for i in range(n):
		if (not b[i]) or x <= i < x+k:
			res[i] = False
	return res

a = [True for _ in range(n+1)]
a[n] = False
while True:
	for i in range(n):
		if a[i]:
			c = cop(a, 1, i)
			if calc(c) == 0:
				print(1, i+1, flush=True)
				a[i] = False
				break
		if a[i] and a[i+1]:
			c = cop(a, 2, i)
			if calc(c) == 0:
				print(2, i+1, flush=True)
				a[i], a[i+1] = False, False
				break
	e = int(input())
	if e <= 1:
		exit()
	elif e == 2:
		input()
		exit()
	k, x = map(int, input().split())
	a[x-1], a[x+k-2] = False, False
	#print(a)
0