CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:VirtuesL
Submission time:2019-10-12 19:32:29 +0300
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.02 sdetails
#20.02 sdetails
#30.02 sdetails
#40.06 sdetails
#50.94 sdetails
#6--details

Code

while True:
x = int(input())
fl = [[i+1 for i in range(x)] if j == 0 else [0 for i in range(x)] for j in range(x)]
def pront():
return "\n".join([" ".join(map(str,l)) for l in fl])
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):
cols = list(zip(*fl[:l]))
for (i, val), col in zip(enumerate(lt), cols):
if val in col:
return (i, val)
def correct(lt,l):
for i, _ in enumerate(lt):
conf = conflict(lt, l)
if conf:
pos, val = conflict(lt,l)
cols = list(zip(*fl[:l]))
for j in range(x):
if val not in cols[::-1][j]:
lt[pos] = lt[x-(j+1)]
lt[x-(j+1)] = val
break
conf = conflict(lt,l)
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(fl[i])
correct(fl[i+2],i+2)
print(pront())

Test details

Test 1

Verdict:

input
1

correct output

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 57, in <module>
    fl[1]...

Test 2

Verdict:

input
2

correct output
1 2 
2 1 

user output
1 2
2 1

Error:
Traceback (most recent call last):
  File "input/code.py", line 2, in <module>
    x = int...

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
1 2 3 4 5
2 1 4 5 3
3 4 5 1 2
4 5 2 3 1
5 3 1 2 4

Error:
Traceback (most recent call last):
  File "input/code.py", line 2, in <module>
    x = int...

Test 4

Verdict:

input
42

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

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

Error:
Traceback (most recent call last):
  File "input/code.py", line 2, in <module>
    x = int...

Test 5

Verdict:

input
99

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

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

Error:
Traceback (most recent call last):
  File "input/code.py", line 2, in <module>
    x = int...

Test 6

Verdict:

input
100

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

user output
(empty)