답안 #43347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43347 2018-03-13T20:47:59 Z Hassoony Prosjecni (COCI16_prosjecni) C++14
0 / 120
2 ms 692 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MX=109;
int n,a[MX][MX];
int main(){
    scanf("%d",&n);
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    if(n==2){
        puts("-1");
        return 0;
    }
    int cnt=1;
    for(int i=1;i<=n-1;i++){
        for(int j=1;j<=n-1;j++){
            a[i][j]=cnt;
            cnt+=n;
        }
        a[i][n-1]+=3*n;
        cnt=(i+1)*n+2;
    }
    for(int i=1;i<=n-1;i++){
        int sum=0;
        for(int j=1;j<=n-1;j++){
            sum+=a[i][j];
        }
        a[i][n]=sum/(n-1);
    }
    for(int i=1;i<=n;i++){
        int sum=0;
        for(int j=1;j<=n-1;j++){
            sum+=a[j][i];
        }
        a[n][i]=sum/(n-1);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
}

Compilation message

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Not distinct
2 Incorrect 2 ms 352 KB Not distinct
3 Incorrect 2 ms 556 KB Not distinct
4 Incorrect 2 ms 556 KB Not distinct
5 Incorrect 1 ms 556 KB Not distinct
6 Incorrect 2 ms 556 KB Not distinct
7 Incorrect 2 ms 556 KB Not distinct
8 Incorrect 2 ms 556 KB Not distinct
9 Incorrect 2 ms 564 KB Not distinct
10 Incorrect 2 ms 692 KB Not distinct