Task: | Ruudukko |
Sender: | jannejal |
Submission time: | 2019-10-01 18:32:45 +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.46 s | details |
#5 | ACCEPTED | 0.91 s | details |
#6 | ACCEPTED | 0.92 s | 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++; while (some1(ret, x, y, alku) || ret[y].some(r => r === alku)) alku++; return alku; }; const some1 = (ret, x, y, alku) => { for (let i = 0; i <= y; i++) { if (ret[i][x] === alku) return true; } }; // const some2 = (ret, x, y, alku) => { // for (let i = 0; i < x; i++) { // if (ret[y][i] === alku) return true; // } // };
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 |