// Maximum-TNT #include #include #include #include #include #include #include #include #include using namespace std; #define cin fin const int BUFSIZE = 1024; ifstream fin("ant.txt"); struct planet_t { int id, x, y; planet_t() {} }; bool operator<(const planet_t& a,const planet_t& b) { return a.y < b.y || (a.y == b.y && a.x < b.x); } planet_t operator-(planet_t a,planet_t b) { a.x -= b.x; a.y -= b.y; return a; } int Naiseki(planet_t a,planet_t b) { return a.x*b.x+a.y*b.y; } double Abs(planet_t a) { return sqrt((double)a.x*a.x+a.y*a.y); } vector g_planet; int g_n; vector g_ans; vector g_flg; const double ERROR=1e-10; void Solve() { sort(g_planet.begin(),g_planet.end()); planet_t start; start.x = 0; start.y = g_planet[0].y; g_planet.push_back(start); int now = 0,prev=g_n; while(true) { planet_t direc = g_planet[now]- g_planet[prev]; int index = -1; double max_cos=-10,len=Abs(direc),min_len=-1; g_ans.push_back(g_planet[now].id); g_flg[now] = 1; for(int j = 0 ; j < g_n ; j++) if(!g_flg[j]) { planet_t d = g_planet[j]-g_planet[now]; double tmp_len= Abs(d); double tmp_cos = Naiseki(d,direc)/(tmp_len*len); if(tmp_cos - ERROR > max_cos) { max_cos = tmp_cos; min_len = tmp_len; index = j; } else if(tmp_cos+ERROR > max_cos) { if(min_len > tmp_len) { index = j; min_len = tmp_len; } } } if(index == -1)break; prev = now; now = index; } } int main() { int m; cin >> m; while(m--) { cin >> g_n; g_planet.assign(g_n,planet_t()); g_ans.clear(); g_flg.assign(g_n,0); for(int i = 0 ; i < g_n ; i++) cin >> g_planet[i].id >> g_planet[i].x >> g_planet[i].y; Solve(); cout << g_ans.size(); for(int i = 0 ; i < (int)g_ans.size() ; i++) cout << ' ' << g_ans[i]; cout << endl; } return 0; }