#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; ll D[2020]; int mi=1010; int tot() { int E[12][12]; int x,y,z; FOR(x,N+2) FOR(y,N+2) E[y][x]=(y==x)?0:2000; for(x=1;x<=N;x++) { for(y=x-1;y>=0;y--) if(D[y]>=D[x]) { E[y][x]=E[x][y]=1; break; } for(y=x+1;y<=N+1;y++) if(D[y]>=D[x]) { E[y][x]=E[x][y]=1; break; } } FOR(z,N+2) FOR(x,N+2) FOR(y,N+2) E[x][y]=min(E[x][y],E[x][z]+E[z][y]); int tot=0; for(x=1;x<=N;x++) for(y=1;y<=N;y++) tot+=E[y][x]; return tot; } void dfs(int mask,int nex) { int i; if(mask==(1<0;sm=(sm-1)&lef) { FOR(i,N) if(sm&(1<>N; D[0]=D[N+1]=2000000000; vector V; /* FOR(i,N-1) V.push_back(i+1); V.push_back(N-1); dfs(0,1); */ /* do { FOR(i,N) D[i+1]=V[i]; x=tot(); if(x<=mi) { mi=x; FOR(i,N) cout<