CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:ossikoo
Submission time:2019-10-10 16:11:26 +0300
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.02 sdetails
#2ACCEPTED0.02 sdetails
#30.02 sdetails
#40.04 sdetails
#50.45 sdetails
#60.47 sdetails

Code

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

def get_lowest_int(grid, n_row, n_col):    
    if n_col == 0 and n_row == 0: return 1

    row_vals = n_col > 0 and grid[n_row][0:n_col] or []
    
    col_vals = []
    for n_upper_row in range(0, n_row):
        col_vals.append(grid[n_upper_row][n_col])

    taken_vals = row_vals + col_vals
    # find lowest missing integer in range 1 to len(grid)
    for val in range(0, len(grid)):
        val += 1
        if not val in taken_vals:
            return val


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

    for n_row, row in enumerate(grid):
        for n_col in range(0, len(row)):
            row[n_col] = get_lowest_int(grid, n_row, n_col)
        print(' '.join(map(str, row)))

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

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

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

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