CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:bruh420
Submission time:2020-10-07 18:22:55 +0300
Language:C++ (C++11)
Status:READY
Result:27
Feedback
groupverdictscore
#1ACCEPTED27
#20
#30
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
#8--2, 3details
#9--2, 3details
#10--2, 3details
#11--3details
#12--3details
#13--3details

Compiler report

input/code.cpp:106:0: warning: ignoring #pragma GCC options_pop [-Wunknown-pragmas]
 #pragma GCC options_pop
 
input/code.cpp: In function 'int main()':
input/code.cpp:83:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int ite = 0; ite < naapuriV.size(); ite++) { // auto & n : naapurit(p, koko) mit� ??????
                    ~~~~^~~~~~~~~~~~~~~~~

Code

// g++ -std=c++11 -O2 -Wall ratsunreitit.cpp -o ratsunreitit
#include<bits/stdc++.h>
#pragma GCC push_options
#pragma GCC optimize ("-O2")
using namespace std;
struct Piste {
int x, y, matka;
};
bool oleva(Piste p, int koko) {
if(p.x < 0 || p.y < 0)
return false;
else if(p.x >= koko || p.y >= koko)
return false;
else{
return true;
}
}
#pragma GCC optimize ("-O0")
vector<Piste>naapurit(Piste p, int koko) {
const int xliike[] { +1, +2, +2, +1, -1, -2, -2, -1 };
const int yliike[] { -2, -1, +1, +2, +2, +1, -1, -2 };
vector<Piste> ret;
for(int i = 0; i < 8; i ++) {
Piste tyo;
tyo.x = p.x + xliike[i];
tyo.y = p.y + yliike[i];
if(oleva(tyo, koko)) {
ret.push_back(tyo);
}
}
return ret;
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC optimize ("-O3")
/*#pragma GCC push_options
#pragma GCC optimize ("-O1")
Piste popback(vector<Piste> *jono) {
Piste p = jono.back();
jono.pop_back();
return p;
}
#pragma GCC pop_options*/
int main() {
int koko;
cin >> koko;
if(koko < 4) return -1;
//vector<vector<int>> ruudukko;
short ruudukko[koko][koko];
vector<Piste> jono;
for( int y = 0; y < koko; y++) {
for( int x = 0; x < koko; x++) {
ruudukko[x][y] = SHRT_MAX;
Piste tyo;
tyo.x = x; tyo.y = y;
jono.push_back(tyo);
}
}
ruudukko[0][0] = 0;
//cout << jono.empty() << endl;
vector<Piste> naapuriV;
while(!jono.empty()) {
Piste p = jono.back();
jono.pop_back(); // Piste n: naapurit(p, koko)
naapuriV = naapurit(p, koko);
/*for(int i = 0; i < naapuriV.size(); i++) {
cout << naapuriV[i].x << naapuriV[i].y << endl;
}*/
//cout << p.x << p.y << endl;
//cout << naapuriV.size() << endl;
for(int ite = 0; ite < naapuriV.size(); ite++) { // auto & n : naapurit(p, koko) mit� ??????
Piste n = naapuriV[ite];
if(ruudukko[n.x][n.y] > ruudukko[p.x][p.y]) {
ruudukko[n.x][n.y] = ruudukko[p.x][p.y] + 1;
jono.push_back(n);
}
}
naapuriV.clear();
}
for(int i = 0; i < koko; i++) {
ruudukko[0][i] = ruudukko[i][0];
}
for(int y = 0; y < koko; y++) {
for(int x = 0; x < koko; x++) {
cout << ruudukko[x][y] << " ";
}
cout << endl;
}
return 0;
}
#pragma GCC options_pop

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

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

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

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

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
(empty)

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
(empty)

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
(empty)

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
(empty)

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)