Task: | Ruudukko |
Sender: | antti_p |
Submission time: | 2019-10-08 10:15:30 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'void ruudukko()': input/code.cpp:27:50: warning: 'min' may be used uninitialized in this function [-Wmaybe-uninitialized] std::cout << min << (c == input - 1 ? "" : " "); ^
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) { included[matrix[r*input + left] - 1] = true; } int min; for (int i = 0; i < 2*input; ++i) { if (!included[i]) { min = i + 1; break; } } matrix[r*input + c] = min; std::cout << min << (c == input - 1 ? "" : " "); } std::cout << "\n"; } delete[] matrix; delete[] included; } int main() { ruudukko(); return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
1 2 2 1 |
user output |
---|
1 2 2 1 |
Test 3
Verdict: ACCEPTED
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 6 3 4 1 2 7 4 3 2 1 8 5 6 7 8 1 |
Test 4
Verdict: ACCEPTED
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 ... Truncated |
Test 5
Verdict: ACCEPTED
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 ... Truncated |
Test 6
Verdict: ACCEPTED
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 ... Truncated |