2019-11-30 08:16:16

// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int cmp(pair<ll,int> a,pair<ll,int> b) { return b<a; }
ll X=0,w=1; char c=getchar();
while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
return X*w;
}

const int N=1000+10;

int n; ll S[N]; int sgn[N];
vector<pair<ll,int> > L,R,LL,LR,RL,RR;

int main() {
for (re int i=3;i<=n;++i) {
if (sgn[i]>0) L.push_back(make_pair(S[i],i));
else R.push_back(make_pair(S[i],i));
}
sort(L.begin(),L.end()),sort(R.begin(),R.end());
for (re int i=3;i<=n;++i) {
if (sgn[i]>0) {
if (i==L.back().second) continue;
printf("2 1 %d %d\n",L.back().second,i),fflush(stdout);
else LR.push_back(make_pair(S[i],i));
} else {
if (i==R.back().second) continue;
printf("2 1 %d %d\n",R.back().second,i),fflush(stdout);
else RR.push_back(make_pair(S[i],i));
}
}
sort(LL.begin(),LL.end(),cmp),sort(LR.begin(),LR.end());
sort(RL.begin(),RL.end(),cmp),sort(RR.begin(),RR.end());
printf("0 1 ");
for (re auto i:RR) printf("%d ",i.second);
if (!R.empty()) printf("%d ",R.back().second);
for (re auto i:RL) printf("%d ",i.second);
printf("2 ");
for (re auto i:LR) printf("%d ",i.second);
if (!L.empty()) printf("%d ",L.back().second);
for (re auto i:LL) printf("%d ",i.second);
puts(""); fflush(stdout);
return 0;
}
• star
首页