CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Lookas123
Submission time:2020-10-11 19:42:39 +0300
Language:Node.js
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.44 s1, 2, 3details
#20.44 s1, 2, 3details
#30.44 s1, 2, 3details
#40.44 s1, 2, 3details
#50.44 s1, 2, 3details
#60.44 s1, 2, 3details
#70.44 s1, 2, 3details
#80.47 s2, 3details
#90.56 s2, 3details
#100.56 s2, 3details
#110.81 s3details
#12--3details
#13--3details

Code

var readline = require('readline');
 
const r = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
let grid=[];
let gridsize;
let checking = [];
r.on('line', function (line) {
    gridsize = Number(line);
    let array=[];
    for (let i = 0; i < gridsize; i++) {
        array.push(Infinity);
    }
    for (let i = 0; i < gridsize; i++) {
        grid.push([...array]);
    }
    grid[0][0]=0;
    checking.push([0,0,0])
    while(checking.length > 0){
        if(checking[0]!==0){
        for(let i in checking){
            let me = checking[i]
            if(i > 0 && arrayIsArray(me,checking[0])){
                checking[i]=0;
            }
        }
        checkpointall(checking[0][0],checking[0][1],checking[0][2]);
        }
        checking.shift();
    }
    for(let item of grid){
        console.log(item.join(" "));
    }
});
function arrayIsArray(arr1, arr2) {
    if(arr1.length !== arr2.length)
        return false;
    for(var i = arr1.length; i--;) {
        if(arr1[i] !== arr2[i])
            return false;
    }
    return true;
}

function setpoint(x, y, amount){
    if(x<0 || x>=gridsize || y<0 || y>=gridsize || grid[y][x] < amount) return false;
    grid[y][x]=amount;
    return true;
}
function checkpointall(x,y,amount){
    if(x<0 || x>=gridsize || y<0 || y>=gridsize || grid[y][x] < amount) return;
    for(let i of [[x+2, y+1],[x+2, y+1],[x+2, y-1],[x+1, y+2],[x+1, y-2],[x-1, y+2],[x-1, y-2],[x-2, y+1],[x-2, y+1]]){
        if(setpoint(i[0],i[1],amount+1)) checking.push([i[0], i[1], amount+1])
    }
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
4

correct output
0 3 2 5 
3 4 1 2 
2 1 4 3 
5 2 3 2 

user output
0 3 2 5
3 4 1 2
2 1 4 3
5 2 3 2

Test 2

Group: 1, 2, 3

Verdict:

input
5

correct output
0 3 2 3 2 
3 4 1 2 3 
2 1 4 3 2 
3 2 3 2 3 
2 3 2 3 4 

user output
0 3 2 3 2
3 4 1 2 3
2 1 4 3 2
5 2 3 2 3
2 3 2 3 4

Test 3

Group: 1, 2, 3

Verdict:

input
6

correct output
0 3 2 3 2 3 
3 4 1 2 3 4 
2 1 4 3 2 3 
3 2 3 2 3 4 
2 3 2 3 4 3 
...

user output
0 3 2 3 2 3
3 4 1 2 3 4
2 1 4 3 2 3
5 2 3 2 3 4
2 3 2 3 4 3
...

Test 4

Group: 1, 2, 3

Verdict:

input
7

correct output
0 3 2 3 2 3 4 
3 4 1 2 3 4 3 
2 1 4 3 2 3 4 
3 2 3 2 3 4 3 
2 3 2 3 4 3 4 
...

user output
0 3 2 3 2 3 4
3 4 1 2 3 4 3
2 1 4 3 2 3 4
5 2 3 2 3 4 3
2 3 2 3 4 3 4
...

Test 5

Group: 1, 2, 3

Verdict:

input
8

correct output
0 3 2 3 2 3 4 5 
3 4 1 2 3 4 3 4 
2 1 4 3 2 3 4 5 
3 2 3 2 3 4 3 4 
2 3 2 3 4 3 4 5 
...

user output
0 3 2 3 2 3 4 5
3 4 1 2 3 4 3 4
2 1 4 3 2 3 4 5
5 2 3 2 3 4 3 4
2 3 2 3 4 3 4 5
...

Test 6

Group: 1, 2, 3

Verdict:

input
9

correct output
0 3 2 3 2 3 4 5 4 
3 4 1 2 3 4 3 4 5 
2 1 4 3 2 3 4 5 4 
3 2 3 2 3 4 3 4 5 
2 3 2 3 4 3 4 5 4 
...

user output
0 3 2 3 2 3 4 5 4
3 4 1 2 3 4 3 4 5
2 1 4 3 2 3 4 5 4
5 2 3 2 3 4 3 4 5
2 3 2 3 4 3 4 5 4
...

Test 7

Group: 1, 2, 3

Verdict:

input
10

correct output
0 3 2 3 2 3 4 5 4 5 
3 4 1 2 3 4 3 4 5 6 
2 1 4 3 2 3 4 5 4 5 
3 2 3 2 3 4 3 4 5 6 
2 3 2 3 4 3 4 5 4 5 
...

user output
0 3 2 3 2 3 4 5 4 5
3 4 1 2 3 4 3 4 5 6
2 1 4 3 2 3 4 5 4 5
5 2 3 2 3 4 3 4 5 6
2 3 2 3 4 3 4 5 4 5
...

Test 8

Group: 2, 3

Verdict:

input
25

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 9

Group: 2, 3

Verdict:

input
49

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 10

Group: 2, 3

Verdict:

input
50

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 11

Group: 3

Verdict:

input
75

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 12

Group: 3

Verdict:

input
99

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
(empty)

Test 13

Group: 3

Verdict:

input
100

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
(empty)