# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147026 | AXork | Prosjecni (COCI16_prosjecni) | C++14 | 9 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 <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
using namespace std;
int main() {
int n;
cin >>n;
int brr;
int br = 1;
int mat[110][110];
if (n == 2) {
cout <<-1;
return 0;
}
if (n%2 == 0) {
for (int i=0; i<n-1; i++) {
brr = 0;
for (int j=0; j<n; j++) {
if (j == n-1) {
br = (br-1) * n - brr;
}
mat[i][j] = br;
//cout <<br <<" ";
brr+=br;
br++;
}
//cout <<"\n";
}
int br = 0;
for (int i=0; i<n; i++) {
brr = 0;
for (int j=0; j<n-1; j++) {
brr+=mat[j][i];
br = mat[j][i];
}
br = br * n - brr;
mat[n-1][i] = br;
}
}
else {
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
cout <<br <<" ";
br++;
}
cout <<"\n";
}
return 0;
}
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
cout <<mat[i][j] <<" ";
}
cout <<"\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |