Submission #43344

# Submission time Handle Problem Language Result Execution time Memory
43344 2018-03-13T20:26:53 Z Hassoony Prosjecni (COCI16_prosjecni) C++14
0 / 120
2 ms 644 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==0){
        puts("-1");
        return 0;
    }
    int cnt=-1;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-1;j++){
            a[i][j]=cnt+=2;
        }
    }
    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;
    }
    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;
    }
    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 Integer -1 violates the range [0, 1000000000]
2 Incorrect 1 ms 356 KB Average condition doesn't hold.
3 Incorrect 1 ms 396 KB Integer -1 violates the range [0, 1000000000]
4 Incorrect 1 ms 504 KB Average condition doesn't hold.
5 Incorrect 1 ms 504 KB Integer -1 violates the range [0, 1000000000]
6 Incorrect 1 ms 504 KB Integer -1 violates the range [0, 1000000000]
7 Incorrect 1 ms 504 KB Integer -1 violates the range [0, 1000000000]
8 Incorrect 1 ms 632 KB Integer -1 violates the range [0, 1000000000]
9 Incorrect 2 ms 644 KB Integer -1 violates the range [0, 1000000000]
10 Incorrect 1 ms 644 KB Integer -1 violates the range [0, 1000000000]