CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:EeliH
Submission time:2020-09-28 11:36:03 +0300
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED27
#2ACCEPTED31
#3ACCEPTED42
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s2, 3details
#9ACCEPTED0.03 s2, 3details
#10ACCEPTED0.03 s2, 3details
#11ACCEPTED0.11 s3details
#12ACCEPTED0.32 s3details
#13ACCEPTED0.30 s3details

Code

#include <iostream>

using namespace std;

void seuraava_ruutu(int, int, int, int);
bool seuraava(int, int, int, int);
bool onko_tyhja(int, int);

int lauta[100][100];

int maara = 0;
int koko;

int main() {
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            lauta[i][j] = -1;
        }
    }
    cin >> koko;
    lauta[0][0] = 0;
    seuraava_ruutu(0, 0, -1, -1);
    for(int i = 0; i < koko; i++) {
        for(int j = 0; j < koko; j++) {
            cout << lauta[i][j] << " ";
        }
        cout << endl;
    }
}

void seuraava_ruutu(int x, int y, int edellinen_x, int edellinen_y) {
    bool a = seuraava(x+2, y+1, x, y);
    bool b = seuraava(x+2, y-1, x, y);
    bool c = seuraava(x-2, y+1, x, y);
    bool d = seuraava(x-2, y-1, x, y);
    bool e = seuraava(x+1, y+2, x, y);
    bool f = seuraava(x-1, y+2, x, y);
    bool g = seuraava(x+1, y-2, x, y);
    bool h = seuraava(x-1, y-2, x, y);
    maara++;
    if(a)
        seuraava_ruutu(x+2, y+1, x, y);
    if(b)    
        seuraava_ruutu(x+2, y-1, x, y);
    if(c)
        seuraava_ruutu(x-2, y+1, x, y);
    if(d)
        seuraava_ruutu(x-2, y-1, x, y);
    if(e)
        seuraava_ruutu(x+1, y+2, x, y);
    if(f)
        seuraava_ruutu(x-1, y+2, x, y);
    if(g)
        seuraava_ruutu(x+1, y-2, x, y);
    if(h)
        seuraava_ruutu(x-1, y-2, x, y);
    maara--;
}

bool seuraava(int x, int y, int edellinen_x, int edellinen_y) {
    if(onko_tyhja(x, y)) {
        lauta[x][y] = maara + 1;
        //seuraava_ruutu(x, y, edellinen_x, edellinen_y);
        //maara--;
        return true;
    }
    return false;
}

bool onko_tyhja(int x, int y) {
    if(x >= 0 && y >= 0 && x < koko && y < koko) {
        return lauta[x][y] == -1 || lauta[x][y] > maara+1;
    }
    return false;
}

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

input
99

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 13

Group: 3

Verdict: ACCEPTED

input
100

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 ...