Submission details
Task:Palindromi
Sender:Attack_Heli
Submission time:2025-10-30 10:21:32 +0200
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.02 sdetails
#20.02 sdetails
#30.02 sdetails
#40.02 sdetails
#50.02 sdetails
#60.02 sdetails
#70.02 sdetails
#80.02 sdetails
#90.02 sdetails
#100.02 sdetails

Code

def recursive(target_x,target_y,depth,checklist:list) -> int:
    new_checklist=[]
    for x,y in checklist:
        if x==target_x or y==target_y:
            return depth
        for i in range(m):
            if r[x][i]=="." and i not in checked_columns:
                checked_columns.append(i)
                new_checklist.append((x,i))
        for i in range(n):
            if r[i][y]=="." and i not in checked_rows:
                checked_rows.append(i)
                new_checklist.append((i,y))
    if not new_checklist:return -1
    return recursive(target_x,target_y,depth+1,new_checklist)
    
(n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
r,k=[l[0] for l in raw_inp[:n]],raw_inp[n:]
checked_rows,checked_columns=[],[]
for x1,y1,x2,y2 in k:
    checked_columns=[y1-1]
    checked_rows=[x1-1]
    print(recursive(x2-1,y2-1,1,[(x1-1,y1-1)]) if (x1,y1) != (x2,y2) else 0)

Test details

Test 1 (public)

Verdict:

input
datatahti

correct output
3

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 2 (public)

Verdict:

input
saippuakauppias

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 3 (public)

Verdict:

input
a

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 4 (public)

Verdict:

input
aa

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 5 (public)

Verdict:

input
abc

correct output
1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 6 (public)

Verdict:

input
aybabtu

correct output
2

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 7 (public)

Verdict:

input
abacabaca

correct output
2

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 8 (public)

Verdict:

input
bbbbaaaababbbbbaabaaabaaaaabab...

correct output
23

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 9 (public)

Verdict:

input
acbaaabaabaddaccdcccbcdbdddacd...

correct output
38

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)

Test 10 (public)

Verdict:

input
uaqtmfftecryanvpshxsodjrllqnqp...

correct output
49

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 17, in <module>
    (n,m,q),*raw_inp=[[int(c) if c.isdigit() else c for c in l.split()] for l in open(0)]
ValueError: not enough values to unpack (expected 3, got 1)