| Task: | Ratsun reitit |
| Sender: | Sartec |
| Submission time: | 2020-10-02 09:52:06 +0300 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #3 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #4 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #5 | WRONG ANSWER | 0.03 s | 1, 2, 3 | details |
| #6 | WRONG ANSWER | 0.04 s | 1, 2, 3 | details |
| #7 | WRONG ANSWER | 0.04 s | 1, 2, 3 | details |
| #8 | WRONG ANSWER | 0.81 s | 2, 3 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #11 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
n2 = int(input(""))
class cell:
def __init__(self, x = 0, y = 0, dist = 0):
self.x = x
self.y = y
self.dist = dist
#
# print(n2)
#
if n2 < 4:
print("n has to greater than 3")
else:
dp = [[0 for i in range(n2)] for j in range(n2)];
print(len(dp))
# 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,row) in enumerate(dp):
for (x, number) in enumerate(row):
if x==n2-1:
print(f'{stepsToPoint(x+1,n2-y)}', end="\n")
else:
print(f'{stepsToPoint(x+1,n2-y)}', end=" ")
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 4 |
| correct output |
|---|
| 0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
| user output |
|---|
| 4 0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
| 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 |
|---|
| 5 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: WRONG ANSWER
| 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 |
|---|
| 6 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: WRONG ANSWER
| 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 |
|---|
| 7 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 ... Truncated |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
| 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 |
|---|
| 8 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 ... Truncated |
Test 6
Group: 1, 2, 3
Verdict: WRONG ANSWER
| 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 |
|---|
| 9 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 ... Truncated |
Test 7
Group: 1, 2, 3
Verdict: WRONG ANSWER
| 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 |
|---|
| 10 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 ... Truncated |
Test 8
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 25 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| 25 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 9
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 49 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
Test 10
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 50 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 75 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 99 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
