CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Eljas
Submission time:2020-09-30 18:45:35 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s1, 2, 3details
#30.01 s1, 2, 3details
#40.01 s1, 2, 3details
#50.01 s1, 2, 3details
#60.01 s1, 2, 3details
#70.01 s1, 2, 3details
#80.01 s2, 3details
#90.01 s2, 3details
#100.01 s2, 3details
#110.01 s3details
#120.01 s3details
#130.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:51:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (size_t i = 0; i < n; i++)
                     ~~^~~

Code

#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
std::queue<std::pair<int, int>> queue;
std::vector<std::vector<bool>> used;
std::vector<std::vector<int>> values;
int n;
const std::set<std::pair<int, int>> offsets = { {-2,-1} ,{-1,-2}, {1,-2} ,{2,-1} ,{-1,2} ,{-2,1} ,{2,1} ,{1,2} };
bool isInside(int y, int x) {
if (y < 0 || x < 0) {
return false;
}
if (y >= n || x >= n)
{
return false;
}
return true;
}
void process() {
std::pair<int, int> current = queue.front();
queue.pop();
for (std::pair<int, int> offset : offsets)
{
std::pair<int, int> n = std::make_pair(current.first + offset.first, current.second + offset.second);
if (isInside(n.first, n.second))
{
if (used[n.first][n.second] == false)
{
values[n.first][n.second] = values[current.first][current.second] + 1;
queue.push(n);
used[n.first][n.second] = true;
}
}
}
}
int main() {
std::cin >> n;
values.resize(n);
used.resize(n);
for (size_t i = 0; i < n; i++)
{
values[i].resize(n);
used[i].resize(n);
}
values[0][0] = 0;
used[0][0] = true;
queue.push(std::make_pair(0, 0));
while (!queue.empty())
{
process();
}
for (auto arr : values)
{
for (int i : arr) {
std::cout << i;
}
std::cout << "\n";
}
return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
4

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

user output
0325
3412
2143
5232

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
03232
34123
21432
32323
23234

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
032323
341234
214323
323234
232343
...

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
0323234
3412343
2143234
3232343
2323434
...

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
03232345
34123434
21432345
32323434
23234345
...

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
032323454
341234345
214323454
323234345
232343454
...

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
0323234545
3412343456
2143234545
3232343456
2323434545
...
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
032323454567678989101110111213...
Truncated

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

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

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

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

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