QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#701769 | #5250. Combination Locks | nekoyellow | TL | 0ms | 0kb | Python3 | 840b | 2024-11-02 14:41:26 | 2024-11-02 14:41:26 |
Judging History
answer
Z, O = '=', '.'
def gray(n):
if n == 1:
return [Z, O]
return list(map(lambda x: Z+x, gray(n-1))) + list(map(lambda x: O+x, list(reversed(gray(n-1)))))
def solve():
n, c = map(int, input().split())
a, b = input(), input()
st = set()
for _ in range(c):
st.add(input())
g = gray(n)
N = 1<<n
bad = [0]*(N)
for i in range(N):
bad[i] = (g[i] in st)
i = g.index(''.join((Z if x == y else O) for x, y in zip(a, b)))
l, r = 0, 0
j = i
while not bad[j]:
l += 1
j = (j-1+N)%N
j = i
while not bad[j]:
r += 1
j = (j+1)%N
if (l & 1) != (r & 1):
print("Alice")
elif (l & 1):
print("Bob")
else:
print("Alice")
for _ in range(int(input())):
solve()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
2 1 0 0 0 1 1 0 0 .