CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Kertor
Submission time:2020-09-30 17:53:51 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.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

Code

#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int PrintArray[100*100];
struct Tiles
{
int x, y;
int Distance;
Tiles() {}
Tiles(int x, int y, int Distance) : x(x), y(y), Distance(Distance) {}
};
void minimumTile(int x, int y, int n)
{
int TileArray[n][n];
int MovementX[] = {-2,-1,1,2,-2,-1,1,2};
int MovementY[] = {-1,-2,-2,-1,1,2,2,1};
int CurrentPosition[] = {1,n};
//int GetTo[] = {x,y};
queue<Tiles> BFS_Queue;
BFS_Queue.push(Tiles(CurrentPosition[0], CurrentPosition[1], 0));
Tiles CurrentTile;
int X_Axis, Y_Axis;
bool BFS_Visit_Bool[n+1][n+1];
for (int b = 1; b <= n; b++)
for (int m = 1; m <= n; m++)
BFS_Visit_Bool[b][m] = false;
BFS_Visit_Bool[CurrentPosition[0]][CurrentPosition[1]] = true;
while(!BFS_Queue.empty())
{
CurrentTile = BFS_Queue.front();
BFS_Queue.pop();
//if(CurrentTile.x == GetTo[0] && CurrentTile.y == GetTo[1])
//return CurrentTile.Distance;
for(int g = 0; g < 8; g++)
{
X_Axis = CurrentTile.x + MovementX[g];
Y_Axis = CurrentTile.y + MovementY[g];
bool WeAreOnBoard = (X_Axis >= 1 && X_Axis <= n && Y_Axis >= 1 && Y_Axis <= n);
if(WeAreOnBoard && !BFS_Visit_Bool[X_Axis][Y_Axis])
{
BFS_Visit_Bool[X_Axis][Y_Axis] = true;
BFS_Queue.push(Tiles(X_Axis, Y_Axis, CurrentTile.Distance + 1));
TileArray[X_Axis][Y_Axis] = CurrentTile.Distance + 1;
}
}
}
TileArray[1][n] = 0;
int o = 0;
for(int y = n; y > 0; y--)
{
for(int x = 1; x <= n; x++)
{
//cout << TileArray[x][y] << " ";
PrintArray[o] = TileArray[x][y];
o++;
}
//cout << '\n';
}
}
int main() {
int n;
cin >> n;
int N_Word = 0;
minimumTile(n,n,n);
for(int y = n; y > 0; y--)
{
for(int x = 1; x <= n; x++)
{
cout << PrintArray[N_Word] << " ";
N_Word++;
}
cout << '\n';
}
return 0;
}

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

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

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

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

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

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

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)