CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:antti_p
Submission time:2019-10-08 10:09:45 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#20.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails

Compiler report

input/code.cpp: In function 'void ruudukko()':
input/code.cpp:29:14: warning: 'min' may be used uninitialized in this function [-Wmaybe-uninitialized]
    std::cout << min;
    ~~~~~~~~~~^~~~~~

Code

#include <iostream>

void ruudukko() {
	int input;
	std::cin >> input;
	int* matrix = new int[input*input];
	bool* included = new bool[2*input];
	for (int r = 0; r < input; ++r) {
		for (int c = 0; c < input; ++c) {
			for (int i = 0; i < 2*input; ++i) {
				included[i] = false;
			}
			for (int top = 0; top < r; ++top) {
				included[matrix[top*input + c] - 1] = true;
			}
			for (int left = 0; left < c; ++left) {
				//std::cout << "Iter: |" << matrix[r*input + left] << "| ";
				included[matrix[r*input + left] - 1] = true;
			}
			int min;
			for (int i = 0; i < 2*input; ++i) {
				//std::cout << "in[" << i << "] = " << included[i];
				if (!included[i]) {
					min = i + 1;
					break;
				}
			}
			matrix[r*input + c] = min;
			std::cout << min;
		}
		std::cout << "\n";
	}
	delete[] matrix;
	delete[] included;
}

int main() {
	ruudukko();
	return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output
1

Test 2

Verdict:

input
2

correct output
1 2 
2 1 

user output
12
21

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
12345
21436
34127
43218
56781

Test 4

Verdict:

input
42

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

user output
123456789101112131415161718192...
Truncated

Test 5

Verdict:

input
99

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

user output
123456789101112131415161718192...
Truncated

Test 6

Verdict:

input
100

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

user output
123456789101112131415161718192...
Truncated