#ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; void solve_test(istream &cin, ostream &cout) { int n; cin >> n; vector x(n), y(n); for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; vector> dist(n, vector(n)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { const int dx = x[i] - x[j], dy = y[i] - y[j]; dist[i][j] = sqrtl((ll)dx * dx + (ll)dy * dy); } ld best = 1e100; vector where; auto work = [&] (const vector &p) { ld cur = 0; for (int i = 0; i + 1 < n; i++) cur += dist[p[i]][p[i + 1]]; if (best > cur) { best = cur; where = p; } }; vector p(n); iota(p.begin(), p.end(), 0); if (n <= 10) { do { work(p); } while (next_permutation(p.begin(), p.end())); } else { mt19937 rng; while (clock() / (double)CLOCKS_PER_SEC < 1.9) { shuffle(p.begin(), p.end(), rng); work(p); } } for (const int it : where) cout << it + 1 << " "; cout << endl; } void solve(istream &cin = std::cin, ostream &cout = std::cout) { solve_test(cin, cout); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed; #ifdef LOCAL auto st = clock(); ifstream fin("../input.txt"); do { solve(fin); cout << "===" << endl; string str; while (getline(fin, str) && str != string(max(1, (int) str.size()), '=')); } while (fin); cout << setprecision(6) << "clock: " << double(clock() - st) / CLOCKS_PER_SEC << endl; #else solve(); #endif return 0; }