CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Anniiiz
Submission time:2020-09-29 14:32:21 +0300
Language: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.02 s2, 3details
#110.02 s3details
#120.02 s3details
#130.02 s3details

Code

class paikka:
  def __init__(self, x = 0, y = 0, matka = 0):
    self.x = x
    self.y = y
    self.matka = matka

def on_laudalla(x, y, n):
  if x >= 1 and x <= n and y >= 1 and y <= n:
    return True
  return False

def minimi_maaliin(heppa, maali, n):
  x_vaihtoehto = [2, 2, -2, -2, 1, 1, -1, -1]
  y_vaihtoehto = [1, -1, 1, -1, 2, -2, 2, -2]
  jono = []
  jono.append(paikka(heppa[0], heppa[1], 0))
  kayty = [[False for i in range(n+1)] for j in range(n+1)]
  kayty[heppa[0]] [heppa[1]] = True
  while len(jono) > 0:
    a = jono[0]
    jono.pop(0)
    if(a.x == maali[0] and
      a.y == maali[1]):
      return a.matka
    for i in range(8):
      x = a.x + x_vaihtoehto[i]
      y = a.y + y_vaihtoehto[i]
      if(on_laudalla(x, y, n) and not kayty[x][y]):
        kayty[x][y] = True
        jono.append(paikka(x, y, a.matka + 1))



def main():
  n = int(input())
  heppa = [1, 1]
  for i in range(1, n+1):
    for j in range(1, n+1):
      maali = [i, j]
      print(minimi_maaliin(heppa, maali, n + " "), end = "")
    print("")





main()

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'

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
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 47, in <module>
    main()
  File "input/code.py", line 40, in main
    print(minimi_maaliin(heppa, maali, n + " "), end = "")
TypeError: unsupported operand type(s) for +: 'int' and 'str'