#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000000000000ll
#define MOD 1000000007
#define N 1000006
#define M 15000005
#define LOG 20
#define KOK 650
#define EPS 0.00001
using namespace std;
int n;
int us[205];
vector<int> vals;
void solve() {
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
printf("%d ",vals[(j+i)%n]);
}
puts("");
}
exit(0);
}
int main() {
//freopen("input.txt","r",stdin);
scanf("%d",&n);
if(n&1) {
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
printf("%d ",2*((j+i)%n+1));
}
puts("");
}
return 0;
}
vals.pb(n);
us[n]=1;
int tot=(n-4)/2;
for(int i=1;i<=tot/2;i++) {
vals.pb(i);
vals.pb(2*n-i);
us[i]=1;
us[2*n-i]=1;
}
for(int i=1;i<2*n;i++) {
if(us[i]) continue ;
for(int j=i+1;j<2*n;j++) {
if(us[j]) continue ;
for(int k=j+1;k<=2*n;k++) {
if(us[k]) continue ;
if(i+j+k==3*n) {
vals.pb(i);
vals.pb(j);
vals.pb(k);
solve();
}
}
}
}
printf("-1");
}
Compilation message
prosjecni.cpp: In function 'int main()':
prosjecni.cpp:54:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Not distinct |
2 |
Incorrect |
2 ms |
376 KB |
Not distinct |
3 |
Incorrect |
2 ms |
256 KB |
Not distinct |
4 |
Incorrect |
2 ms |
256 KB |
Not distinct |
5 |
Incorrect |
2 ms |
256 KB |
Not distinct |
6 |
Incorrect |
2 ms |
256 KB |
Not distinct |
7 |
Incorrect |
2 ms |
376 KB |
Not distinct |
8 |
Incorrect |
2 ms |
376 KB |
Not distinct |
9 |
Incorrect |
2 ms |
376 KB |
Not distinct |
10 |
Incorrect |
3 ms |
376 KB |
Not distinct |