QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#701789#5250. Combination LocksnekoyellowWA 15ms10716kbPython3918b2024-11-02 14:43:062024-11-02 14:43:10

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 14:43:10]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:10716kb
  • [2024-11-02 14:43:06]
  • 提交

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'