# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
301843 | 2020-09-18T08:48:48 Z | colazcy | Prosjecni (COCI16_prosjecni) | C++17 | 2 ms | 384 KB |
#include <cstdio> using namespace std; const int maxn = 128; int val[maxn][maxn],n; int main(){ scanf("%d",&n); if(n % 2 == 1){ int tot = 0; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++)printf("%d ",++tot); printf("\n"); } return 0; } if(n == 2)return puts("-1"),0; for(int i = 1;i < n;i++)val[1][i] = i; int sum = 0; for(int i = 1;i < n;i++)sum += val[1][i]; val[1][n] = val[1][n - 1] * n - sum; for(int i = 2;i < n;i++) for(int j = 1;j <= n;j++) val[i][j] = val[i - 1][j] + val[1][n - 1]; for(int i = 1;i <= n;i++){ int sum = 0; for(int j = 1;j < n;j++)sum += val[j][i]; val[n][i] = val[n - 1][i] * n - sum; } for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++)printf("%d ",val[i][j]); printf("\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Not distinct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Incorrect | 0 ms | 256 KB | Not distinct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Incorrect | 1 ms | 256 KB | Not distinct |
6 | Incorrect | 1 ms | 384 KB | Not distinct |
7 | Incorrect | 1 ms | 384 KB | Not distinct |
8 | Incorrect | 1 ms | 384 KB | Not distinct |
9 | Incorrect | 2 ms | 384 KB | Not distinct |
10 | Incorrect | 2 ms | 384 KB | Not distinct |