CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Lookas123
Submission time:2020-10-11 20:19:10 +0300
Language:Node.js
Status:READY
Result:58
Feedback
groupverdictscore
#1ACCEPTED27
#2ACCEPTED31
#30
Test results
testverdicttimegroup
#1ACCEPTED0.44 s1, 2, 3details
#2ACCEPTED0.44 s1, 2, 3details
#3ACCEPTED0.44 s1, 2, 3details
#4ACCEPTED0.44 s1, 2, 3details
#5ACCEPTED0.44 s1, 2, 3details
#6ACCEPTED0.44 s1, 2, 3details
#7ACCEPTED0.44 s1, 2, 3details
#8ACCEPTED0.47 s2, 3details
#9ACCEPTED0.55 s2, 3details
#10ACCEPTED0.56 s2, 3details
#11ACCEPTED0.79 s3details
#12--3details
#13--3details

Code

const { timeStamp } = require('console');
var readline = require('readline');
const { start } = require('repl');
 
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 = gridsize; i--;) {
        array.push(Infinity);
    }
    for (let i = gridsize; i--;) {
        grid.push(array.slice(0));
    }
    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(let i = 0; i<3; 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: ACCEPTED

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
3 2 3 2 3
2 3 2 3 4

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

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
3 2 3 2 3 4
2 3 2 3 4 3
...

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

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
3 2 3 2 3 4 3
2 3 2 3 4 3 4
...

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

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

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

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

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

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)