CSES - Datatähti 2021 alku - Results
Submission details
Task:Ratsun reitit
Sender:motsgar
Submission time:2020-10-03 17:57:16 +0300
Language:C++17
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:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable: 4996)
 
input/code.cpp: In function 'int main()':
input/code.cpp:84:3: warning: value computed is not used [-Wunused-value]
   *output++;
   ^~~~~~~~~
input/code.cpp:85:3: warning: value computed is not used [-Wunused-value]
   *output++;
   ^~~~~~~~~
input/code.cpp:86:3: warning: value computed is not used [-Wunused-value]
   *output++;
   ^~~~~~~~~
input/code.cpp:91:3: warning: value computed is not used [-Wunused-value]
   *output--;
   ^~~~~~~~~
input/code.cpp:92:3: warning: value computed is not used [-Wunused-value]
   *output--;
   ^~~~~~~~~
input/code.cpp:93:3: warning: value computed is not used [-Wunused-value]
   *output--;
   ^~~~~~~~~
input/code.cpp:47:33: warning: 'cellValue' may be used uninitialized in this function [-Wmaybe-uninitialized]
    outputInt[y * boardSize + x] = cellValue;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
input/code.cpp:38:36: warning: 'st...

Code

#pragma warning(disable: 4996)
#include <iostream>
#include <cmath>
#define maxSize 100

using namespace std;

char input[10];
char* output = new char[maxSize * maxSize * 3];
int outputInt[maxSize * maxSize];
int outputIntIndex = 0;

int main() {
	cin.getline(input, sizeof(input));

	int boardSize = 0;

	int j = 0;
	while (input[j] != '\0')
	{
		boardSize = boardSize * 10 + (input[j] - 48);
		j++;
	}

	int cellValue;
	for (int y = 0; y < boardSize; y++) {
		int startValue;
		int height = 0;
		if (y > 3) {
			startValue = y - (y / 4) * 2;
			height = (y - 4) / 2 + y % 2 * 2 + 4;
		}

		int shouldGrow = (y / 2) % 2;

		for (int x = 0; x <= y; x++) {
			if (y > 3 && x < height) {
				if (shouldGrow == 0) cellValue = startValue + x % 2;
				else cellValue = startValue - x % 2;
			}
			else if (x == y) cellValue = ((x - 1) / 3) * 2 + 2;
			else if (y > 3 && x >= height && x < y)
			{
				if (y % 2 == 1) cellValue = x - ((x - height + 2) / 3) * 2 - 1;
				else cellValue = x - ((x - height + 2) / 3) * 2;
			}
			outputInt[y * boardSize + x] = cellValue;
			if (x != y) outputInt[x * boardSize + y] = cellValue;
		}
	}
	outputInt[0] = 0;
	outputInt[1] = 3;
	if (boardSize == 4)
	{
		outputInt[3] = 5;
		outputInt[3 * boardSize] = 5;
	}
	else
	{
		outputInt[3] = 3;
		outputInt[3 * boardSize] = 3;
	}
	outputInt[1 * boardSize + 0] = 3;
	outputInt[1 * boardSize + 1] = 4;
	outputInt[1 * boardSize + 2] = 1;
	outputInt[2 * boardSize + 1] = 1;
	outputInt[2 * boardSize + 2] = 4;
	outputInt[2 * boardSize + 3] = 3;
	outputInt[3 * boardSize + 2] = 3;

	for (int i = 0; i < boardSize * boardSize; i++)
	{
		int numLength;
		if (i != 0) numLength = log10(outputInt[i]) + 1;
		else numLength = 1;

		sprintf(output, "%i", outputInt[i]);
		//itoa(outputInt[i], output, 10);
		output[numLength] = ' ';

		if ((i + 1) % boardSize == 0) output[2] = '\n';
		else output[2] = ' ';

		*output++;
		*output++;
		*output++;
	}
	output[-1] = '\0';
	for (int i = 0; i < boardSize * boardSize; i++)
	{
		*output--;
		*output--;
		*output--;
	}

	printf("%s", output);

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

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

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

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

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

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