# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74105 | charlies_moo | Prosjecni (COCI16_prosjecni) | C++17 | 4 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
int main() {
int n;
scanf("%d", &n);
if (n == 2) {
printf("-1\n");
} else if (n % 2 == 1) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
printf("%d%c", i*n+j+1, j==n-1 ? '\n' : ' ');
}
}
} else {
int k = n / 2;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1; j++) {
printf("%d ", 3*k*i+j+1);
}
printf("%d\n", 3*k*(i+1));
}
for (int j = 0; j < n - 1; j++) {
printf("%d ", 9*k*k-3*k+j+1);
}
printf("%d\n", 9*k*k);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |