QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623124#5730. Maze ConnectTheZachManRE 1066ms155328kbPython31.3kb2024-10-09 10:16:402024-10-09 10:16:41

Judging History

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

  • [2024-10-09 10:16:41]
  • 评测
  • 测评结果:RE
  • 用时:1066ms
  • 内存:155328kb
  • [2024-10-09 10:16:40]
  • 提交

answer

from collections import deque

r, c = map(int, input().split())
lines = []
for i in range(r):
    lines.append(input())

st = None
for i in range(r):
    for j in range(c):
        if lines[i][j] != '.':
            st = (i + j + (lines[i][j] == '\\')) % 2
            break
    if st != None:
        break

o = 0
exposed = {}
q = deque()
for i in range(1,r):
    for j in range((i%2)+st,c,2):
        q.append((i,j))
        E = False
        visited = {}
        while len(q) > 0:
            a, b = q.pop()
            if (a,b) in visited:
                continue
            visited[a,b] = 0
            if (a,b) in exposed:
                E = True
                q.clear()
                break
            if a <= 0 or a >= r or b <= 0 or b >= c:
                E = True
                q.clear()
                break
            if lines[a-1][b-1]=='.':
                q.append((a-1,b-1))
            if lines[a][b-1]=='.':
                q.append((a+1,b-1))
            if lines[a-1][b]=='.':
                q.append((a-1,b+1))
            if lines[a][b]=='.':
                q.append((a+1,b+1))
        if not E:
            o += 1
            for v in q:
                visited[v]=0
        q.clear()
        for k in visited:
            exposed[k]=0
print(o)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 11ms
memory: 10676kb

input:

2 2
/\
\/

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 7ms
memory: 10648kb

input:

4 4
/\..
\.\.
.\/\
..\/

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 14ms
memory: 10708kb

input:

2 2
\/
/\

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 10ms
memory: 10588kb

input:

8 20
/\/\/\/\/\/\/\/\/\/\
\../\.\/./././\/\/\/
/./\.././\/\.\/\/\/\
\/\/\.\/\/./\/..\../
/\/./\/\/./..\/\/..\
\.\.././\.\/\/./\.\/
/.../\../..\/./.../\
\/\/\/\/\/\/\/\/\/\/

output:

26

result:

ok single line: '26'

Test #5:

score: 0
Accepted
time: 548ms
memory: 75160kb

input:

1000 1000
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\...

output:

499001

result:

ok single line: '499001'

Test #6:

score: 0
Accepted
time: 551ms
memory: 75248kb

input:

1000 1000
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/...

output:

499000

result:

ok single line: '499000'

Test #7:

score: 0
Accepted
time: 821ms
memory: 84088kb

input:

1000 1000
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\...

output:

122943

result:

ok single line: '122943'

Test #8:

score: 0
Accepted
time: 20ms
memory: 11372kb

input:

100 100
................................................./\.................................................
................................................/..\................................................
.............................................../....\........................................

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 23ms
memory: 11168kb

input:

100 100
................................................./\.................................................
................................................/..\................................................
..............................................././\.\........................................

output:

25

result:

ok single line: '25'

Test #10:

score: 0
Accepted
time: 16ms
memory: 10800kb

input:

40 40
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\...

output:

760

result:

ok single line: '760'

Test #11:

score: 0
Accepted
time: 12ms
memory: 10768kb

input:

40 40
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\...

output:

760

result:

ok single line: '760'

Test #12:

score: 0
Accepted
time: 12ms
memory: 10824kb

input:

21 21
/\/\/\/\/\/\/\/\/\/\.
\...\...\...\...\...\
/././././././././././
\.\.\.\.\.\.\.\.\.\.\
/././././././././././
\.\.\.\.\.\.\.\.\.\.\
/././././././././././
\.\.\.\.\.\.\.\.\.\.\
/././././././././././
\.\.\.\.\.\.\.\.\.\.\
/././././././././././
\.\.\.\.\.\.\.\.\.\.\
/././././././././././
\.\.\.\....

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 1066ms
memory: 155328kb

input:

997 997
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\...

output:

1

result:

ok single line: '1'

Test #14:

score: 0
Accepted
time: 12ms
memory: 10784kb

input:

10 10
..../\....
.../..\...
.././\.\..
././..\.\.
/././\.\.\
\.\.\/././
.\.\.././.
..\.\/./..
...\../...
....\/....

output:

3

result:

ok single line: '3'

Test #15:

score: 0
Accepted
time: 11ms
memory: 10644kb

input:

10 11
...../\....
..../..\...
..././\.\..
.././..\.\.
./././\.\.\
.\.\.\/././
..\.\.././.
...\.\/./..
....\../...
.....\/....

output:

3

result:

ok single line: '3'

Test #16:

score: -100
Dangerous Syscalls

input:

1000 1000
.....................................................................................................................................................................................................................................................................................................

output:


result: