CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:VirtuesL
Submission time:2019-10-12 16:27:59 +0300
Language:CPython3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.02 sdetails
#20.02 sdetails
#30.02 sdetails
#40.02 sdetails
#50.02 sdetails
#60.02 sdetails

Code

import numpy as np
x = int(input())

fl = np.zeros((x,x), dtype='int')
fl[0] = [i+1 for i in range(x)]

def swapRow(lt):
  tmp = [i for i in lt]
  for i in range(0,x,2):
    try:
      a = tmp[i+1]
      tmp[i+1] = tmp[i]
      tmp[i] = a
    except IndexError:
      a = tmp[i]
      tmp[i] = tmp[i-1]
      tmp[i-1] = a
  return tmp
  
def conflict(lt,l):
  for i, val in enumerate(lt):
    if val in fl[:,i][:l]:
      return (i,val)

def correct(lt,l):
  for i, _ in enumerate(lt):
    conf = conflict(lt,l)
    if conf:
      pos, val = conf
      if val not in fl[:,x-(i+1)][:l]:
        lt[pos] = lt[x-(i+1)]
        lt[x-(i+1)] = val

def swap2Row(lt):
  tmp = [i for i in lt]
  for i in range(x-2):
    a = tmp[i+2]
    tmp[i+2] = tmp[i]
    tmp[i] = a
  if len(tmp)%2 == 0:
    pass
  else:
    a = tmp[x-1]
    tmp[x-1] = tmp[x-2]
    tmp[x-2] = a
  return tmp

fl[1] = swapRow(fl[0])
for i, row in enumerate(fl[:x-2]):
  fl[i+2] = swap2Row(row)
  correct(fl[i+2],i+2)

for l in fl:
  print(" ".join(map(str,l)))

Test details

Test 1

Verdict:

input
1

correct output

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Test 2

Verdict:

input
2

correct output
1 2 
2 1 

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Test 3

Verdict:

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Test 4

Verdict:

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Test 5

Verdict:

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Test 6

Verdict:

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'