Submission #147026

#TimeUsernameProblemLanguageResultExecution timeMemory
147026AXorkProsjecni (COCI16_prosjecni)C++14
120 / 120
9 ms504 KiB
#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 timeMemoryGrader output
Fetching results...