CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:Luukasa
Submission time:2019-09-30 15:42:16 +0300
Language:C++11
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails

Code

#include <iostream>
using namespace std;

int main()
{
	int num;
	cin >> num; // get the input(number of rows and colums)
	int table[num][num]; // create the main table that will be outputted in the end of the program
	//bool usedY[num] = false; // create an array that keeps track of what numbers have been used on the Y row
	bool used[num]; // create an array that keeps track of what numbers have been used on the X row

	for(int i = 0; i < num; i++) // fill table with zeroes
		for(int j = 0; j < num; j++)
			table[i][j] = 0;
	for(int u = 0; u < num; u++)
	{
		used[u] = false;
	}
	for(int y = 0; y < num; y++) // loop that goes through the Y axis
	{
		for(int x = 0; x < num; x++) // loop that goes through the X axis
		{
			for(int i = x; i >= 0; i--) // loop that checks what numbers have been used in the left side of current position on the X axis
			{
				used[int((table[y][i])-1)] = true;
			}
			for(int i = y; i >= 0; i--) // loop that checks what numbers have been used on the Y axis
			{
				used[int((table[i][x])-1)] = true;
			}
			for(int j = 0; j < num; j++)
			{
				if(used[j] == 0)
				{
					for(int i = 0; i < num; i++)
					table[y][x] = j+1;
					break;
				}
			}
			for(int u = 0; u < num; u++)
			{
				used[u] = false;
			}
		}
	}
	for(int i = 0; i < num; i++)
	{
		for(int j = 0; j < num; j++)
			cout << table[i][j] << " ";
		cout << endl;
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2 
2 1 

Test 3

Verdict:

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
1 2 3 4 5 
2 1 4 3 0 
3 4 1 2 0 
4 3 2 1 0 
5 0 0 0 1 

Test 4

Verdict:

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Test 5

Verdict:

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Test 6

Verdict:

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...