CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:siar
Submission time:2020-10-03 13:14:50 +0300
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.02 s1, 2, 3details
#20.02 s1, 2, 3details
#30.02 s1, 2, 3details
#40.02 s1, 2, 3details
#50.02 s1, 2, 3details
#60.02 s1, 2, 3details
#70.02 s1, 2, 3details
#80.02 s2, 3details
#90.02 s2, 3details
#100.03 s2, 3details
#110.02 s3details
#120.03 s3details
#130.03 s3details

Code

ruudukonKoko = int(input(""))
hevonenAloitus = [1, 1]
#mihinHevosenHalutaan = [4, 3]
class cell:
def __init__(self, x=0, y=0, dist=0):
self.x = x
self.y = y
self.dist = dist
#dist "pituus countteri"
def onkoRuudunSisällä(x, y, ruudukonKoko):
if (x >= 1 and x <= ruudukonKoko and y >= 1 and y <= ruudukonKoko):
return True
return False
def lyhyinReittiMihinHevostaHalutaan(hevonenAloitus, mihinHevosenHalutaan, ruudukonKoko):
hevonenX = [2, 2, -2, -2, 1, 1, -1, -1]
hevonenY = [1, -1, 1, -1, 2, -2, 2, -2]
queue = []
queue.append(cell(hevonenAloitus[0], hevonenAloitus[1], 0))
#queue.append(cell)
vierailtu = [[False for i in range(ruudukonKoko + 1)] for j in range(ruudukonKoko + 1)]
vierailtu[hevonenAloitus[0]][hevonenAloitus[1]] = True
while (len(queue) > 0):
i = queue[0]
queue.pop(0)
#print(i.x, " iii-x")
if (i.x == mihinHevosenHalutaan[0] and i.y == mihinHevosenHalutaan[1]):
return i.dist
for i in range(8):
x = i.x + hevonenX[i]
y = i.y + hevonenY[i]
#for x in hevo
if (onkoRuudunSisällä(x, y, ruudukonKoko) and not vierailtu[x][y]):
vierailtu[x][y] = True
#print(vierailtu[1][2])
queue.append(cell(x, y, i.dist + 1))
for ySivu in range(1, ruudukonKoko+1):
for xSivu in range(1, ruudukonKoko+1):
print(lyhyinReittiMihinHevostaHalutaan(hevonenAloitus, [ySivu, xSivu], ruudukonKoko), end = ' ')
print("")
#print(lyhyinReittiMihinHevostaHalutaan(hevonenAloitus, mihinHevosenHalutaan, ruudukonKoko))

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
4

correct output
0 3 2 5 
3 4 1 2 
2 1 4 3 
5 2 3 2 

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 2

Group: 1, 2, 3

Verdict:

input
5

correct output
0 3 2 3 2 
3 4 1 2 3 
2 1 4 3 2 
3 2 3 2 3 
2 3 2 3 4 

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 3

Group: 1, 2, 3

Verdict:

input
6

correct output
0 3 2 3 2 3 
3 4 1 2 3 4 
2 1 4 3 2 3 
3 2 3 2 3 4 
2 3 2 3 4 3 
...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 4

Group: 1, 2, 3

Verdict:

input
7

correct output
0 3 2 3 2 3 4 
3 4 1 2 3 4 3 
2 1 4 3 2 3 4 
3 2 3 2 3 4 3 
2 3 2 3 4 3 4 
...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 5

Group: 1, 2, 3

Verdict:

input
8

correct output
0 3 2 3 2 3 4 5 
3 4 1 2 3 4 3 4 
2 1 4 3 2 3 4 5 
3 2 3 2 3 4 3 4 
2 3 2 3 4 3 4 5 
...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 6

Group: 1, 2, 3

Verdict:

input
9

correct output
0 3 2 3 2 3 4 5 4 
3 4 1 2 3 4 3 4 5 
2 1 4 3 2 3 4 5 4 
3 2 3 2 3 4 3 4 5 
2 3 2 3 4 3 4 5 4 
...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 7

Group: 1, 2, 3

Verdict:

input
10

correct output
0 3 2 3 2 3 4 5 4 5 
3 4 1 2 3 4 3 4 5 6 
2 1 4 3 2 3 4 5 4 5 
3 2 3 2 3 4 3 4 5 6 
2 3 2 3 4 3 4 5 4 5 
...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 8

Group: 2, 3

Verdict:

input
25

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 9

Group: 2, 3

Verdict:

input
49

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 10

Group: 2, 3

Verdict:

input
50

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 11

Group: 3

Verdict:

input
75

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 12

Group: 3

Verdict:

input
99

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...

Test 13

Group: 3

Verdict:

input
100

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output

Error:
Traceback (most recent call last):
  File "input/code.py", line 66, in <module>
    print(...