# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84033 | wjoao | Prosjecni (COCI16_prosjecni) | C++11 | 3 ms | 668 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>
using namespace std;
int n;
int main(){
scanf(" %d", &n);
if( n == 1 ) printf("1\n");
else if( n == 2 ) printf("-1\n");
else if (n%2 == 1){
for(int i = 0, k = 1; i < n; i++){
for(int j = 0; j < n; j++, k++){
if( j != 0 ) printf(" ");
printf("%d", k);
}
printf("\n");
}
}else{
vector<int> ind;
int meio = n*100*100;
ind.push_back(0);
for(int i = 1; i <= n/2; i++) ind.push_back(-i);
for(int i = 1; i <= n/2-2; i++) ind.push_back(i);
ind.push_back(n-1);
for(int i = 0; i < n; i++){
int atual = meio + ind[i]*2*n;
for(int j = 0; j < n; j++){
if( j != 0 ) printf(" ");
printf("%d", atual + ind[j]);
}printf("\n");
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |