Submission #133727

# Submission time Handle Problem Language Result Execution time Memory
133727 2019-07-21T09:05:24 Z forelax Prosjecni (COCI16_prosjecni) C++14
120 / 120
3 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==2){
        cout<<-1;
        return 0;
    }
    if(n%2)
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < n ; j ++){
            cout<<i*n+j+1<<" ";
        }
        cout<<endl;
    }
    else{
    int sm=(n-2)*(n-1)/2;
    int sk=sm+n-1;
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < n ; j ++){
            cout<<i*sk+j+1+(j==n-1?sm-1:0)+(i==n-1?sm*sk-sk:0)<<" ";
        }
        cout<<endl;
    }
    }

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct