CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:victor05
Submission time:2020-10-05 10:47:52 +0300
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED27
#2ACCEPTED31
#3ACCEPTED42
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s2, 3details
#9ACCEPTED0.01 s2, 3details
#10ACCEPTED0.01 s2, 3details
#11ACCEPTED0.01 s3details
#12ACCEPTED0.01 s3details
#13ACCEPTED0.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:6:18: warning: unused variable 'x' [-Wunused-variable]
  int n, i, j, l, x, y;
                  ^
input/code.cpp:6:21: warning: unused variable 'y' [-Wunused-variable]
  int n, i, j, l, x, y;
                     ^
input/code.cpp:7:7: warning: unused variable 'temp' [-Wunused-variable]
  bool temp;
       ^~~~

Code

#include <iostream>

using namespace std;

int main(void) {
	int n, i, j, l, x, y;
	bool temp;

	cin >> n;
	
	int b[n][n];

	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			b[i][j] = 0;
		}
	}

	b[0][0] = 1;

	b[1][2] = 1;
	b[2][1] = 1;

	l = 1;

	for(;;) {
continueloop:
		for(i = 1; i < n; i++) {
			for(j = 0; j < n; j++) {
				if(b[i][j] == l) {
					if(b[i-2][j-1] == 0 && i-2 >= 0 && j-1 >= 0)
						b[i-2][j-1] = b[i][j]+1;
					if(b[i-2][j+1] == 0 && i-2 >= 0 && i < n)
						b[i-2][j+1] = b[i][j]+1;
					if(b[i+2][j-1] == 0 && i+2 < n && j-1 >= 0)
						b[i+2][j-1] = b[i][j]+1;
					if(b[i+2][j+1] == 0 && i+2 < n && j+1 < n)
						b[i+2][j+1] = b[i][j]+1;

					if(b[i-1][j-2] == 0 && i-1 >= 0 && j-2 >= 0)
						b[i-1][j-2] = b[i][j]+1;
					if(b[i-1][j+2] == 0 && i-1 >= 0 && j+2 < n) {
						b[i-1][j+2] = b[i][j]+1;
					}
					if(b[i+1][j-2] == 0 && i+1 < n && j-2 >= 0)
						b[i+1][j-2] = b[i][j]+1;
					if(b[i+1][j+2] == 0 && i+1 < n && j+2 < n)
						b[i+1][j+2] = b[i][j]+1;
				}
			}
		}

		l++;
		
		for(i = 0; i < n; i++) {
			for(j = 0; j < n; j++)
				if(b[i][j] == 0) {
					goto continueloop;
				}
		}
		goto endofloop;
	}

endofloop:

	b[0][0] = 0;

	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			cout << b[i][j] << " ";
		}

		cout << endl;
	}
	
	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: ACCEPTED

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 3 2 3 2 
3 4 1 2 3 
2 1 4 3 2 
3 2 3 2 3 
2 3 2 3 4 

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

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

Test 8

Group: 2, 3

Verdict: ACCEPTED

input
25

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 9

Group: 2, 3

Verdict: ACCEPTED

input
49

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 10

Group: 2, 3

Verdict: ACCEPTED

input
50

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 11

Group: 3

Verdict: ACCEPTED

input
75

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 12

Group: 3

Verdict: ACCEPTED

input
99

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

Test 13

Group: 3

Verdict: ACCEPTED

input
100

correct output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...

user output
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ...