CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:Kertor
Submission time:2020-09-30 14:13:08 +0300
Language:C++11
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 minimumTile(int, int, int)':
input/code.cpp:30:6: warning: unused variable 'GetTo' [-Wunused-variable]
  int GetTo[] = {x,y}; 
      ^~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:85:6: warning: unused variable 'a' [-Wunused-variable]
  int a = minimumTile(n,n,n);
      ^

Code

#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <bits/stdc++.h> 
#define ll long long int

using namespace std;

struct Tiles
{
	int x, y;
	int Distance;
	Tiles() {}
	Tiles(int x, int y, int Distance) : x(x), y(y), Distance(Distance) {}
};

int minimumTile(int x, int y, int n)
{
	if(x == 1 && y == n) {return 0;}
	
	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;
			}
		}
	}
	
	for(int y = n; y > 0; y--)
	{
		for(int x = 1; x <= n; x++)
		{
			cout << TileArray[x][y] << " ";
		}
		cout << '\n';
	}
	
	return 0;
}



int main() {
	int n;
	cin >> n;
	int a = minimumTile(n,n,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
1429374688 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
(empty)

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

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)