QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#701789 | #5250. Combination Locks | nekoyellow | WA | 15ms | 10716kb | Python3 | 918b | 2024-11-02 14:43:06 | 2024-11-02 14:43:10 |
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]:
j = (j-1+N)%N
l += 1
if l == N:
break
j = i
while not bad[j]:
j = (j+1)%N
r += 1
if r == N:
break
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: 100
Accepted
time: 15ms
memory: 10652kb
input:
2 1 0 0 0 1 1 0 0 .
output:
Alice Bob
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 14ms
memory: 10716kb
input:
8 2 0 00 00 2 1 00 00 .. 2 1 00 00 =. 2 2 00 00 .. =. 2 1 00 00 .= 2 2 00 00 .. .= 2 2 00 00 =. .= 2 3 00 00 .. =. .=
output:
Alice Alice Bob Alice Bob Alice Bob Bob
result:
ok 8 lines
Test #3:
score: -100
Wrong Answer
time: 12ms
memory: 10708kb
input:
20 4 4 4714 5245 ..=. ..== .==. ==.. 4 1 2697 1438 .=.. 4 5 9255 0677 ...= ..== =..= ==.= ==== 4 12 3292 7326 ...= ..=. ..== .=.. .=.= .==. =... =..= =.== ==.. ==.= ==== 4 9 8455 2536 ...= ..== .=.. .=.= .==. .=== =... ==.. ===. 4 12 5755 1517 ...= ..=. ..== .=.. .=.= .=== =..= =.=. =.== ==.. ==.= =...
output:
Alice Bob Alice Bob Alice Bob Bob Bob Alice Alice Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob
result:
wrong answer 5th lines differ - expected: 'Bob', found: 'Alice'