#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include //#include using namespace std; //using namespace atcoder; typedef vector VI; typedef vector VVI; typedef vector VVVI; typedef long long LL; typedef unsigned long long ULL; typedef pair PII; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repab(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) #define repabc(i, a, b, c) for (int i = (int)(a); i <= (int)(b); i += c) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rrepab(i, a, b) for (int i = (int)(b); i >= (int)(a); i--) #define rrepabc(i, a, b, c) for (int i = (int)(b); i >= (int)(a); i-=c) #define printl(...) cerr << "LINE=" << __LINE__ << " "; print(__VA_ARGS__) #define print_data(variable) cerr << "[DATA] " << #variable << " = " << variable << endl; #define X first #define Y second #define ARGS_SIZE_(a1,a2,a3,a4,a5,a6,a7,a8,a9,size,...) size #define ARGS_SIZE(...) ARGS_SIZE_(__VA_ARGS__,9,8,7,6,5,4,3,2,1) #define DB_1(x) #x << "=" << (x) << #define DB_2(x, ...) #x << "=" << (x) << ", " << DB_1(__VA_ARGS__) #define DB_3(x, ...) #x << "=" << (x) << ", " << DB_2(__VA_ARGS__) #define DB_4(x, ...) #x << "=" << (x) << ", " << DB_3(__VA_ARGS__) #define DB_5(x, ...) #x << "=" << (x) << ", " << DB_4(__VA_ARGS__) #define DB_6(x, ...) #x << "=" << (x) << ", " << DB_5(__VA_ARGS__) #define DB_7(x, ...) #x << "=" << (x) << ", " << DB_6(__VA_ARGS__) #define DB_8(x, ...) #x << "=" << (x) << ", " << DB_7(__VA_ARGS__) #define DB_9(x, ...) #x << "=" << (x) << ", " << DB_8(__VA_ARGS__) #define DB__(size, ...) DB_##size(__VA_ARGS__) #define DB_(size, ...) DB__(size, __VA_ARGS__) #define DB(...) do {cerr << DB_(ARGS_SIZE(__VA_ARGS__), __VA_ARGS__) endl;} while (0) void print() {} template void print(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(Tail) == 0) cerr << endl; else cerr << ", "; print(forward(tail)...); } template ostream& operator << (ostream& os, vector& vec) { os << "{"; for (int i = 0; i>19))^(t^(t>>8)) ); } struct Timer { chrono::system_clock::time_point start_time = chrono::system_clock::now(); chrono::system_clock::time_point end_time = chrono::system_clock::now(); int elapsed() { end_time = chrono::system_clock::now(); return chrono::duration_cast(end_time - start_time).count(); } } timer; void select_2(int &one, int &other, int n) { // [0, n)から相異なる2つを選択 one = randxor() % n; other = randxor() % (n-1); if ( one <= other ) other++; } //static const int dx[] = {0,-1,0,1,1,-1,-1,1}; //static const int dy[] = {-1,0,1,0,1,1,-1,-1}; //static const char dir[] = {'L','U','R','D'}; const int TIME_LIMIT = 900; const int N = 100; const int M = 8; const int alpha = 5; const int alpha2 = 25; const int INF = 101010101; PII planets[N]; PII stations[M]; int p2p[N][N]; struct FloydWarshall { int dist[N][N]; int next[N][N]; void set() { rep(i, N) rep(j, N) {dist[i][j] = alpha2 * ((planets[i].X-planets[j].X)*(planets[i].X-planets[j].X) + (planets[i].Y-planets[j].Y)*(planets[i].Y-planets[j].Y)); next[i][j] = j;} } void calc() { rep(k, N) rep(i, N) rep(j, N) { if (dist[i][k] + dist[k][j] < dist[i][j]) { dist[i][j] = dist[i][k] + dist[k][j]; next[i][j] = next[i][k]; } } } VI get_path(int s, int t) { VI ret; for (int cur = s; cur != t; cur = next[cur][t]) { ret.push_back(cur); } ret.push_back(t); return ret; } } warshall; void load_data() { ios::sync_with_stdio(false); std::cin.tie(nullptr); int _; cin >> _ >> _; rep(i, N) cin >> planets[i].X >> planets[i].Y; } void print_ans(VI &junban) { rep(i, M) cout << stations[i].X << " " << stations[i].Y << endl; VI ans; rep(i, N) { VI add = warshall.get_path(junban[i], junban[i+1]); for (int j: add) ans.push_back(j); } cout << ans.size() << endl; for (int i: ans) cout << "1 " << i+1 << endl; } void solve() { double start_temp = 500; const double end_temp = 0; VI junban; rep(i, N) junban.push_back(i); junban.push_back(0); int now_cost = 0; rep(i, N) now_cost += warshall.dist[junban[i]][junban[i+1]]; int iter = 0; while ( true ) { if ( iter % 100 == 0 ) { if ( timer.elapsed() >= TIME_LIMIT ) break; } iter++; int a, b; select_2(a, b, 100); // (a, a+1)(b, b+1)間をswap if ( a > b ) swap(a, b); int diff = warshall.dist[junban[a]][junban[b]] + warshall.dist[junban[a+1]][junban[b+1]] - warshall.dist[junban[a]][junban[a+1]] - warshall.dist[junban[b]][junban[b+1]]; double temp = start_temp + (end_temp - start_temp) * timer.elapsed() / TIME_LIMIT; double prob = exp(-(double)diff/temp); if ( prob > (randxor() % 10000)/10000.0 ) { reverse(junban.begin() + a + 1, junban.begin() + b + 1); now_cost += diff; } } double score = 1000000000 / (1000.0 + sqrt((double)now_cost)); print_data(score); print_ans(junban); } int main() { load_data(); rep(i, M) {stations[i].X = 0; stations[i].Y = 0;} warshall.set(); warshall.calc(); solve(); }