# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631572 | berr | Prosjecni (COCI16_prosjecni) | C++17 | 2 ms | 724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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=4;
for(int i=4; i<n; i++)
{
a[i]=n+p;
a[i+1]=n-p;
p++;
i++;
}
set<int> st;
for(int i=0; i<n-1; i++)
{
for(int l=0; l<n; l++)
{
cout<<n*2+a[l]<<" ";
a[l]=n*2+a[l];
st.insert(a[l]);
}
cout<<"\n";
}
int add=n*2*(((n-2)*(n-1))/2);
for(auto l: a)
{
cout<<l+add<<" ";
st.insert(l+add);
}
if(st.size()!=n*n) cout<<"aa\n"<<st.size();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |