#include #ifdef LOCAL #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif using namespace std; using ll=long long; // Start 2023.04.23 21:00 // End // Time min // MTK005 constexpr ll TYPE_PLANET = 1; constexpr ll TYPE_STATION = 2; constexpr ll ALPHA = 5; struct Pos { int x,y; ll type; Pos(int x, int y, ll type) : x(x), y(y), type(type) {} }; std::ostream& operator<<(std::ostream& os, const Pos& pos) { std::ostringstream oss; oss << "(" << pos.x << ", " << pos.y << "), " << pos.type << ""; os << oss.str(); return os; } struct Solver { int N = 0; int M = 0; vector points; Solver(int n, int m, vector& points) : N(n),M(m),points(points) {} void test() { debug(N,M,points); } void solve() { // 貪欲法 // 宇宙ステーションの座標は適当に決め打ち set_station(); debug(points); // 惑星1からスタートする // 一番近い惑星+宇宙ステーションを選び続ける vector visited(N+M,0); vector route; visited[0]++; route.push_back(0); int v = 0; for(int i=0; i 0) continue; int d = calc_energy(v,next); if(d < nearest_dist) { nearest_dist = d; nearest_v = next; } debug(d); } // 次の頂点に移動 if(nearest_v != -1) { v = nearest_v; visited[v]++; route.push_back(nearest_v); } } // 最後に惑星1に戻る route.push_back(0); debug(visited); debug(route); output(route); } void output(vector& route) { // 宇宙ステーションの座標 for(int i=N; i> n >> m; // vector a(n),b(n); vector points; for(int i=0; i> a >> b; points.emplace_back(Pos(a,b,TYPE_PLANET)); } debug(n,m,points); Solver solver(n,m,points); solver.solve(); return 0; }