CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:osmo
Submission time:2020-10-05 15:07:26 +0300
Language:CPython3
Status:READY
Result:58
Feedback
groupverdictscore
#1ACCEPTED27
#2ACCEPTED31
#30
Test results
testverdicttimegroup
#1ACCEPTED0.03 s1, 2, 3details
#2ACCEPTED0.03 s1, 2, 3details
#3ACCEPTED0.03 s1, 2, 3details
#4ACCEPTED0.03 s1, 2, 3details
#5ACCEPTED0.03 s1, 2, 3details
#6ACCEPTED0.03 s1, 2, 3details
#7ACCEPTED0.03 s1, 2, 3details
#8ACCEPTED0.08 s2, 3details
#9ACCEPTED0.26 s2, 3details
#10ACCEPTED0.25 s2, 3details
#11ACCEPTED0.57 s3details
#120.92 s3details
#130.95 s3details

Code

n = int(input())

reitit = [[0 for x in range(n)] for y in range(n)]

x_list = 0
y_list = 0
reitit[0][0] = 1

for _ in range(20):
    for y_pos in range(n):
        for x_pos in range(n):  
            if x_pos + 2 < n and y_pos + 1 < n and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos + 1][x_pos + 2] > reitit[y_pos][x_pos] + 1 or reitit[y_pos + 1][x_pos + 2] == 0:
                    reitit[y_pos + 1][x_pos + 2] = reitit[y_pos][x_pos] + 1
            if x_pos + 2 < n and y_pos - 1 >= 0 and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos - 1][x_pos + 2] > reitit[y_pos][x_pos] + 1 or reitit[y_pos - 1][x_pos + 2] == 0:
                    reitit[y_pos - 1][x_pos + 2] = reitit[y_pos][x_pos] + 1
            if x_pos - 2 >= 0 and y_pos + 1 < n and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos + 1][x_pos - 2] > reitit[y_pos][x_pos] + 1 or reitit[y_pos + 1][x_pos - 2] == 0:
                    reitit[y_pos + 1][x_pos - 2] = reitit[y_pos][x_pos] + 1    
            if x_pos - 2 >= 0 and y_pos - 1 >= 0 and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos - 1][x_pos - 2] > reitit[y_pos][x_pos] + 1 or reitit[y_pos - 1][x_pos - 2] == 0:
                    reitit[y_pos - 1][x_pos - 2] = reitit[y_pos][x_pos] + 1
            if x_pos + 1 < n and y_pos + 2 < n and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos + 2][x_pos + 1] > reitit[y_pos][x_pos] + 1 or reitit[y_pos + 2][x_pos + 1] == 0:
                    reitit[y_pos + 2][x_pos + 1] = reitit[y_pos][x_pos] + 1   
            if x_pos - 1 >= 0 and y_pos + 2 < n and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos + 2][x_pos - 1] > reitit[y_pos][x_pos] + 1 or reitit[y_pos + 2][x_pos - 1] == 0:
                    reitit[y_pos + 2][x_pos - 1] = reitit[y_pos][x_pos] + 1
            if x_pos + 1 < n and y_pos - 2 >= 0 and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos - 2][x_pos + 1] > reitit[y_pos][x_pos] + 1 or reitit[y_pos - 2][x_pos + 1] == 0:
                    reitit[y_pos - 2][x_pos + 1] = reitit[y_pos][x_pos] + 1     
            if x_pos - 1 >= 0 and y_pos - 2 >= 0 and reitit[y_pos][x_pos] != 0:
                if reitit[y_pos - 2][x_pos - 1] > reitit[y_pos][x_pos] + 1 or reitit[y_pos - 2][x_pos - 1] == 0:
                    reitit[y_pos - 2][x_pos - 1] = reitit[y_pos][x_pos] + 1    

for temp_y in range(n):
    print("")
    for temp_x in range(n):
        print(str(reitit[temp_y][temp_x] - 1) + " ", end = '')

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
4

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

user output

0 3 2 5 
3 4 1 2 
2 1 4 3 
5 2 3 2 

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

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

0 3 2 3 2 
3 4 1 2 3 
2 1 4 3 2 
3 2 3 2 3 
...

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

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

0 3 2 3 2 3 
3 4 1 2 3 4 
2 1 4 3 2 3 
3 2 3 2 3 4 
...

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

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

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 
...

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

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

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 
...

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

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

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 
...

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

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

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 
...

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
25

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

user output

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

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
49

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

user output

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

Test 10

Group: 2, 3

Verdict: ACCEPTED

input
50

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

user output

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

Test 11

Group: 3

Verdict: ACCEPTED

input
75

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

user output

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

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

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

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

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