CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:ossikoo
Submission time:2019-10-10 14:48:44 +0300
Language:CPython3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.02 sdetails
#2ACCEPTED0.02 sdetails
#30.02 sdetails
#40.03 sdetails
#50.03 sdetails
#60.03 sdetails

Code

def generate_empty_grid(n):
    grid = []
    for row in range(0, n):
        grid.insert(row, [0] * n)
    return grid

def get_int(n_col, n_offset, n):
    v = n_col + n_offset + 1
    if v > n:
        return v - n
    else:
        return v

def get_new_offset(cur_offset, n):
    new_offset = cur_offset + 1
    if new_offset > n:
        new_offset = 0
    return new_offset

def main(n):
    grid = generate_empty_grid(n)

    n_offset = 0
    for n_row, row in enumerate(grid):
        for n_col in range(0, len(row)):
            v = get_int(n_col, n_offset, n)
            row[n_col] = v
            if n_col == len(row) - 1:
                print(v, end = '')
            else:
                print(v, end = ' ')
        n_offset = get_new_offset(n_offset, n)
        if n_row != len(grid) - 1:
            print("\n", end = '')


main(int(input()))

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output
1

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2
2 1

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

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 ...

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 ...

Test 6

Verdict:

input
100

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 ...