# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146783 | fabjanm | Prosjecni (COCI16_prosjecni) | C++98 | 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<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int mat[105][105];
int niz[105];
int main(){
int n;
cin>>n;
if(n==1){
cout<<1;
return 0;
}
if(n % 2 == 1){
int br=2*n;
int poc=n*10;
for(int i=0;i<n;i++){
mat[i][n/2+1]=poc;
poc+=br*2;
}
for(int i=0;i<n;i++){
int poc=mat[i][n/2+1];
for(int j=0;j<n;j++){
mat[i][j]=poc-2*(n/2-j);
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<mat[i][j]<<" ";
}
cout<<endl;
}
}
else{
if(n==2){
cout<<-1;
return 0;
}
for(int i=0;i<n-1;i++)niz[i]=i+1;
int br=n*(n-1)/2;
niz[n-1]=br;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
mat[i][j]=br*niz[i]+niz[j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<mat[i][j]<<" ";
}
cout<<endl;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |