CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:jannejal
Submission time:2019-10-01 18:19:38 +0300
Language:Node.js
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.43 sdetails
#2ACCEPTED0.43 sdetails
#3ACCEPTED0.43 sdetails
#4ACCEPTED0.50 sdetails
#5--details
#6--details

Code

let readline = require('readline');

var r = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

let input = null;
r.on('line', line => {
    input = line;
    run(input);
    process.exit();
});

const run = line => {
    // console.time();
    const times = Number(line);
    const ret = [];
    for (let y = 0; y < times; y++) {
        ret.push([]);
        for (let x = 0; x < times; x++) {
            ret[y].push(minInVertical(ret, x, y));
        }
        console.log(ret[y].join(" "));
    }
    // console.timeEnd();
};

const minInVertical = (ret, x, y) => {
    let alku = 1;
    while (ret.map(r => r[x]).some(r => r === alku) || ret[y].some(r => r === alku)) alku++;
    return alku;
};

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: ACCEPTED

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

Test 4

Verdict: ACCEPTED

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

Test 6

Verdict:

input
100

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

user output
(empty)