Submission #43346

# Submission time Handle Problem Language Result Execution time Memory
43346 2018-03-13T20:41:58 Z Hassoony Prosjecni (COCI16_prosjecni) C++14
0 / 120
3 ms 688 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;
    if(n%2==0)cnt++;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-1;j++){
            a[i][j]=cnt;
            cnt+=n+n%2;
        }
        a[i][n-2]+=n;
        cnt++;
    }
    for(int i=0;i<n-1;i++){
        int sum=0;
        for(int j=0;j<n-1;j++){
            sum+=a[i][j];
        }
        a[i][n-1]=sum/(n-1);
    }
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<n-1;j++){
            sum+=a[j][i];
        }
        a[n-1][i]=sum/(n-1);
    }
    for(int i=0;i<n;i++){
        for(int j=0;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);
                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 248 KB Not distinct
2 Incorrect 1 ms 352 KB Not distinct
3 Incorrect 1 ms 404 KB Not distinct
4 Incorrect 2 ms 484 KB Not distinct
5 Incorrect 1 ms 512 KB Not distinct
6 Incorrect 2 ms 528 KB Not distinct
7 Incorrect 2 ms 572 KB Not distinct
8 Incorrect 2 ms 588 KB Not distinct
9 Incorrect 3 ms 688 KB Not distinct
10 Incorrect 2 ms 688 KB Not distinct