# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94151 | ekrem | Prosjecni (COCI16_prosjecni) | C++98 | 3 ms | 444 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 <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 105
using namespace std;
int n, a[N][N];
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d",&n);
if(n == 2){
puts("-1");
return 0;
}
if(n % 2){
for(int i = 1; i <= n; i++,puts(""))
for(int j = 1; j <= n; j++)
printf("%d ", (i - 1)*n + j);
return 0;
}
for(int j = 1; j <= n; j++){
if(j == n/2)
a[1][j] = a[1][j - 1] + 3;
else
a[1][j] = a[1][j - 1] + 1;
}
int ek = a[1][n];
for(int i = 2; i <= n; i++)
for(int j = 1; j <= n; j++){
if(i == n/2)
a[i][j] = a[i - 1][j] + 3*ek;
else
a[i][j] = a[i - 1][j] + ek;
}
for(int i = 1; i <= n; i++,puts(""))
for(int j = 1; j <= n; j++)
printf("%d ", a[i][j]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |