Task: | Ruudukko |
Sender: | AtskaFin |
Submission time: | 2019-09-30 20:03:02 +0300 |
Language: | Node.js |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.43 s | details |
#2 | ACCEPTED | 0.43 s | details |
#3 | ACCEPTED | 0.43 s | details |
#4 | ACCEPTED | 0.44 s | details |
#5 | ACCEPTED | 0.55 s | details |
#6 | ACCEPTED | 0.55 s | details |
Code
const readLine = require('readline') const read = readLine.createInterface({ input: process.stdin, output: process.stdout, terminal: false }); read.on('line', n => { let grid = [[]] let row = [] for(let i = 0; i < n; i++) grid[0][i] = i + 1 for(let a = 1; a < n; a++) { row.push(grid.length + 1) for(let b = 1; b < n; b++) { let num = 0 while(true) { num++ let doesFit = true for(let c = 0; c < grid.length; c++) { if(grid[c][row.length] == num) doesFit = false } if(!doesFit) continue if(!row.includes(num)) break } row.push(num) } grid.push(row) row = [] } for(let i = 0; i < grid.length; i++) { console.log(grid[i].join(' ')) } })
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 |
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: ACCEPTED
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: ACCEPTED
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 |