CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:Luukasa
Submission time:2019-09-30 14:46:00 +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[j][i] = 0;
	for(int i = 0; i < num; i++) // fill the used table with false's
			used[i] = 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 = 0; i < num; i++) // loop that checks what numbers have been used on the X axis
			{
				if(table[i][y] == 0){}

				else
				{
					used[int(table[i][y]-1)] = true;
				}
			}
			for(int i = 0; i < num; i++) // loop that checks what numbers have been used on the Y axis
			{
				if(table[x][i] == 0)
					break;
				else
				{
					used[int(table[x][i]-1)] = true;
				}
			}
			for(int j = 0; j < num; j++)
			{
				if(!used[j])
					table[x][y] = j+1;
			}
			for(int i = 0; i < num; i++)
				used[i] = false;
		}
	}
	for(int i = num-1; i >= 0; i--)
	{
		for(int j = 0; j < num; j++)
			cout << table[j][i] << " ";
		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 0 0 0 5 
2 3 4 5 0 
3 2 5 4 0 
4 5 2 3 0 
5 4 3 2 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 0 0 0 0 0 0 10 9 8 7 6 5 4...

Test 5

Verdict:

input
99

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

user output
1 0 3 2 0 0 0 0 0 0 0 0 0 0 0 ...

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