CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:budhi
Submission time:2020-10-07 18:00:10 +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

Code

#include <bits/stdc++.h>

using namespace std;

int main() {

	int boardsize;
	cin >> boardsize;
	
	/* initialize the board */
	
	int board [boardsize][boardsize];
	//board [i][j]
	
	for (int i = 0; i < boardsize; i++)
	{
		for (int j = 0; j < boardsize; j++)
		{
			board[i][j] = 0;
		}
	}
	
	
	//board[1][0] = 1; //yksi alas
	//board[0][1] = 2; //yksi vasemmalle
	
	//kuvio!!!
	
	//1-tuota kuvio
	//2-peilaa kuvio
	
	//laudan laajetessa numeroille muodostuu selkeitä säännönmukaisuuksia
	//algoritmi perustuu näihin säännönmukaisuuksiin
	
	//viistojana alas
	
	for (int n = 1; n < boardsize; n++)
	{
		//alkaa kohdasta 1,1
		board[n][n] = ceil((float)n / 3) * 2;
	}
	
	//ensimmäiset kaksi viistojanassa ovat nelosia
	board[1][1] = 4;
	board[2][2] = 4;
	
	/*
	for (int m = 0; m < boardsize; m++)
	{
        for (int n = 1; n < boardsize; n++)
		{
			if (2*n < boardsize)
			{
				board[n][2*n+m] = n+m;
			}
			else
			{
				n=999999;
			}
		}
	}
	*/
	
	//säännölliset rivit?
	
	for (int m = 0; m < boardsize; m++)
	{
		for (int n = 0; n < boardsize; n++)
	    {
	        
	        if (n+2*m < boardsize)
	        {
	             board[m][n+2*m] = n - 2*(floor((float)n/4)) + m;
	        }
		   else
		   {
		       n=9999;
		   }
	    }
	}
	
		
	//ylärivin toinen jäsen on 3 lähtöpaikan kulmarajoitteiden takia
	board[0][1] = 3;
	
	//viistojanan ja säännöllisten ylärivien välissä olevat luvut voidaan tutkia ratsuliikuilla
	
	//löytää nollat ja korvaa ne
	for (int m = 2; m < boardsize; m++)
	{
	    for (int n = 1; n < m; n++)
	    {
	        if (m+n < boardsize)
	        {
	            //nollan kohdalla
	            //kohdan arvo on kaksi ylempänä ja yksi vasemmalla olevan olevan arvo +1
	            board[m][m+n] = board[m-2][m+n-1] + 1;
	        }
	        else 
	        {
	            n=999;
	        }
	    }
	}
	
	//jos laudan koko on 4, oikea yläkulma on 5, eikä 3. Tämä johtuu reunojen rajoituksista
	if (boardsize == 4)
	{
	    board[0][3] = 5;
	}
	
	//peilaa lauta
	for (int m = 1; m < boardsize; m++)
	{
		for (int n = 0; n < m; n++)
		{
			board[m][n] = board[n][m];
		}
	}
	
	/* print out the board */
	for (int i = 0; i < boardsize; i++)
	{
		for (int j = 0; j < boardsize; j++)
		{
			cout << board[i][j];
			if (j < boardsize - 1)
			{
				cout << " ";
			}
		}
		if (i < boardsize - 1)
		{
			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: 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 ...