-
Notifications
You must be signed in to change notification settings - Fork 7
/
asedatab2.py3
37 lines (33 loc) · 921 Bytes
/
asedatab2.py3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) 2022 kamyu. All rights reserved.
#
# Google Code Jam 2022 Round 1B - Problem C. ASeDatAb
# https://codingcompetitions.withgoogle.com/codejam/round/000000000087711b/0000000000acd29b
#
# Time: precompute: O(2^L)
# runtime: O(L * 2^L)
# Space: O(2^L)
#
# python interactive_runner.py python3 testing_tool.py 0 -- python3 asedatab2.py3
#
def save(N):
print(N, flush=True)
return int(input())
def asedatab():
for x in SEQ:
if not save("{:08b}".format(x)):
break
def sequence(L): # Space: O(2^L)
result = [1]
l = 1
while l != L:
new_result = [(x<<l)|x for x in result]
for x in result:
new_result.append(x)
new_result.extend((x<<l)|x for x in result)
result = new_result
l <<= 1
return result
L = 8 # should be a power of 2
SEQ = sequence(L)
for case in range(int(input())):
asedatab()