| Task: | Ratsun reitit |
| Sender: | Anniiiz |
| Submission time: | 2020-09-29 15:22:41 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #2 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #4 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #8 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #11 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int minimimatka(int*, int*, int)': input/code.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
Code
#include <bits/stdc++.h>
using namespace std;
struct paikka {
int x, y;
int matka;
paikka() {}
paikka(int x, int y, int matka)
: x(x), y(y), matka(matka)
{
}
};
bool laudalla(int x, int y, int n)
{
if (x >= 1 && x <= n && y >= 1 && y <= n)
return true;
return false;
}
int minimimatka(int heppa[], int maali[], int n)
{
int x_vaihtoehto[] = { 1, 1, -1, -1, 2, 2, -2, -2 };
int y_vaihtoehto[] = { 2, -2, 2, -2, 1, -1, 1, -1 };
queue<paikka> q;
q.push(paikka(heppa[0], heppa[1], 0));
paikka a;
int x, y;
bool kayty[n+1][n+1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
kayty[i][j] = false;
kayty[heppa[0]][heppa[1]] = true;
while (!q.empty()) {
a = q.front();
q.pop();
if (a.x == maali[0] && a.y == maali[1])
return a.matka;
for (int i = 0; i < 8; i++) {
x = a.x + x_vaihtoehto[i];
y = a.y + y_vaihtoehto[i];
if (laudalla(x, y, n) && !kayty[x][y]) {
kayty[x][y] = true;
q.push(paikka(x, y, a.matka + 1));
}
}
}
}
int main()
{
int n;
cin >> n;
int heppa[] = { 1, 1 };
for (int i = 1; i < n + 1; i++) {
for (int j = 1; i < n +1; j++) {
int maali[] = { i, j };
cout << minimimatka(heppa, maali, 0);
}
cout << "\n";
}
return 0;
}
Test details
Test 1
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 4 |
| correct output |
|---|
| 0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
| user output |
|---|
| (empty) |
Test 2
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| 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: TIME LIMIT EXCEEDED
| input |
|---|
| 100 |
| correct output |
|---|
| 0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
| user output |
|---|
| (empty) |
