# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
147129 | badrovinho | Prosjecni (COCI16_prosjecni) | C++14 | 4 ms | 452 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int mat[105][105];
int main (){
int n;
cin >> n;
if (n % 2 == 1){
int x = 1;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cout << x << " ";
x++;
}
cout << "\n";
}
}else {
if (n == 2){
cout << -1;
}else {
//GLAVNO
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
mat[i][j] = 0;
}
}
int k = 1;
int suma = 0;
for (int i = 0; i < n-1; i++){
mat[0][i] = k;
suma += k;
k++;
}
int pr = mat[0][n/2];
int x = (n*pr)-suma;
mat[0][n-1] = x;
for (int i = 1; i < n-1; i++){
mat[i][0] = mat[i-1][n-1] + 1;
int suma = mat[i][0];
for (int j = 1; j < n-1; j++){
mat[i][j] = mat[i][j-1] + 1;
suma += mat[i][j];
}
int pr = mat[i][n/2];
int x = (n*pr)-suma;
mat[i][n-1] = x;
}
for (int j = 0; j < n; j++){
int suma = 0;
for (int i = 0; i < n-1; i++){
suma += mat[i][j];
}
int pr = mat[n/2][j];
int x = (n*pr)-suma;
mat[n-1][j] = x;
}
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... |