# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
631570 | dozer | Prosjecni (COCI16_prosjecni) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define N 105
#define modulo 1000000007
#define int long long
int arr[N][N];
int32_t main()
{
fastio();
int n;
cin>>n;
if (n == 1)
{
cout<<1<<endl;
return 0;
}
if (n == 2)
{
cout<<-1<<endl;
return 0;
}
if (n % 2 == 0)
{
int sum = 0;
for (int i = 1; i < n; i++)
{
arr[i][1] = arr[i - 1][n] + 1;
sum += arr[i][1];
for (int j = 2; j < n; j++)
arr[i][j] = arr[i][j - 1] + 1;
arr[i][n] = arr[i][n - 1] + (n / 2) + 1;
}
int w = arr[n / 2 + 1][1] * n;
arr[n][1] = w - sum;
for (int j = 2; j < n; j++)
arr[n][j] = arr[n][j - 1] + 1;
arr[n][n] = arr[n][n - 1] + (n / 2) + 1;
}
else
{
int cntr = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
arr[i][j] = cntr++;
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
cout<<arr[i][j]<<sp;
cout<<endl;
}
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |