답안 #631565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631565 2022-08-18T08:42:19 Z berr Prosjecni (COCI16_prosjecni) C++17
36 / 120
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n; cin>>n;
    if(n==2) cout<<-1<<endl;
    else if(n%2==1)
    {
        for(int i=0; i<n; i++)
        {
            for(int l=1; l<=n; l++)
            {
                cout<<i*n+l<<" ";
            }
            cout<<"\n";
        }
    }
    else
    {
        vector<int> a(n);
        a[0]=n;
        a[1]=n-3;
        a[2]=n+1;
        a[3]=n+2;
        int p=3;
        for(int i=4; i<n; i++)
        {
            a[i]=n+p;
            a[i+1]=n-p;
            p++;
            i++;
        }

        for(int i=0; i<n-1; i++)
        {
            for(auto l: a)
            {
                cout<<i*2*n+l<<" ";
            }
            cout<<"\n";
        }
        int add=n*2*(((n-2)*(n-1))/2);

        for(auto l: a)
        {
            cout<<l+add+(n-2)*n*2<<" ";
        }
    }

}
    
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Not distinct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Not distinct
6 Incorrect 1 ms 212 KB Not distinct
7 Incorrect 1 ms 340 KB Not distinct
8 Incorrect 1 ms 340 KB Not distinct
9 Incorrect 1 ms 340 KB Not distinct
10 Incorrect 1 ms 340 KB Not distinct