| Task: | Ratsun reitit |
| Sender: | Kertor |
| Submission time: | 2020-09-30 15:39:37 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #3 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #4 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
| #5 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
| #6 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
| #7 | RUNTIME ERROR | 0.01 s | 1, 2, 3 | details |
| #8 | RUNTIME ERROR | 0.01 s | 2, 3 | details |
| #9 | RUNTIME ERROR | 0.01 s | 2, 3 | details |
| #10 | RUNTIME ERROR | 0.01 s | 2, 3 | details |
| #11 | RUNTIME ERROR | 0.01 s | 3 | details |
| #12 | RUNTIME ERROR | 0.01 s | 3 | details |
| #13 | RUNTIME ERROR | 0.01 s | 3 | details |
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;
minimumTile(n,n,n);
int N_Word = 0;
for(int y = n; y > 0; y--)
{
for(int x = 1; x <= n; x++)
{
cout << PrintArray[N_Word] << " ";
N_Word++;
}
cout << '\n';
}
}
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: WRONG ANSWER
| 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: WRONG ANSWER
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| 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: RUNTIME ERROR
| input |
|---|
| 100 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
