# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
146747 | fran_1024 | Prosjecni (COCI16_prosjecni) | C++14 | 4 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int x = n * n;
if(x == 4) {
cout << -1;
return 0;
}
int m = 0;
if(n & 1) for(int i = 0; i < x; i++) {
cout << i + 1 << ' ';
if((i + 1) % n == 0) {
cout << '\n';
}
} else {
vector <int> ar(n);
for(int i = 0; i < n; i++) {
ar[i] = i + 1;
}
int x = ar[n / 2] * n - (n * (n - 1) / 2);
ar[n - 1] = x;
int fsum = 0;
int nkd;
for(int i = 0; i < n; i++) {
if(i == n - 1) {
int y = nkd * n - fsum;
for(int j = 0; j < n; j++) {
ar[j] = y + j;
if(j == n - 1) {
ar[j] += x - j - 1;
}
}
}
fsum += ar[0];
if(i == n / 2) nkd = ar[0];
for(int j = 0; j < n; j++) {
cout << ar[j] << ' ';
ar[j] += x;
}
cout << '\n';
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |