QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#701769#5250. Combination LocksnekoyellowTL 0ms0kbPython3840b2024-11-02 14:41:262024-11-02 14:41:26

Judging History

This is the latest submission verdict.

  • [2024-11-02 14:41:26]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-11-02 14:41:26]
  • Submitted

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
.

output:


result: