Task: | Ratsun reitit |
Sender: | Sartec |
Submission time: | 2020-10-02 10:39:19 +0300 |
Language: | Python3 (CPython3) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#2 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#3 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#4 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#5 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#6 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#7 | RUNTIME ERROR | 0.02 s | 1, 2, 3 | details |
#8 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
#9 | RUNTIME ERROR | 0.02 s | 2, 3 | details |
#10 | RUNTIME ERROR | 0.03 s | 2, 3 | details |
#11 | RUNTIME ERROR | 0.02 s | 3 | details |
#12 | RUNTIME ERROR | 0.02 s | 3 | details |
#13 | RUNTIME ERROR | 0.03 s | 3 | details |
Code
import time import numpy start_time = time.time() n2 = int(input("")) dp = [[0 for i in range(n2)] for j in range(n2)]; class cell: def __init__(self, x = 0, y = 0, dist = 0): self.x = x self.y = y self.dist = dist if n2 < 4: print("n has to greater than 3") else: # Python3 code to find minimum steps to reach # to specific cell in minimum moves by Knight # checks whether given position is # inside the board def isInside(x, y, N): if (x >= 1 and x <= N and y >= 1 and y <= N): return True return False # Method returns minimum step to reach # target position def minStepToReachTarget(knightpos, targetpos, N): # all possible movments for the knight dx = [2, 2, -2, -2, 1, 1, -1, -1] dy = [1, -1, 1, -1, 2, -2, 2, -2] queue = [] # push starting position of knight # with 0 distance queue.append(cell(knightpos[0], knightpos[1], 0)) # make all cell unvisited visited = [[False for i in range(N + 1)] for j in range(N + 1)] # visit starting state visited[knightpos[0]][knightpos[1]] = True # loop untill we have one element in queue while(len(queue) > 0): t = queue[0] queue.pop(0) # if current cell is equal to target # cell, return its distance if(t.x == targetpos[0] and t.y == targetpos[1]): return t.dist # iterate for all reachable states for i in range(8): x = t.x + dx[i] y = t.y + dy[i] if(isInside(x, y, N) and not visited[x][y]): visited[x][y] = True queue.append(cell(x, y, t.dist + 1)) # Driver Code def stepsToPoint(targetX, targetY): N = n2 knightpos = [1, n2] targetpos = [targetX, targetY] return minStepToReachTarget(knightpos, targetpos, N) # for (y, row) in enumerate(dp): # for (x, value) in enumerate(row): # dp[y][x] = (stepsToPoint(x+1,n2-y)) for y in range(n2): for x in range(n2): if x==n2-1: print(minStepToReachTarget([1, n2], [x+1,n2-y], n2), end="\n") else: print(minStepToReachTarget([1, n2], [x+1,n2-y], n2), end=" ") # print(*[minStepToReachTarget([1, n2], [x+1,n2-y], n2) for x in range(n2) for y in range(n2)], sep='\n') print("--- %s seconds ---" % (time.time() - start_time))
Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
input |
---|
4 |
correct output |
---|
0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 2
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 3
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 4
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 5
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 6
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 7
Group: 1, 2, 3
Verdict: RUNTIME ERROR
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 |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 8
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
25 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
49 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 10
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
50 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 11
Group: 3
Verdict: RUNTIME ERROR
input |
---|
75 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
99 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
(empty) |
Error:
Traceback (most recent call last): File "input/code.py", line 2, in <module> import...