voidsieve(int n){ minp.assign(n + 1, 0); primes.clear(); for (int i = 2; i <= n; i++) { if (minp[i] == 0) { minp[i] = i; primes.push_back(i); } for (auto p : primes) { if (i * p > n) { break; } minp[i * p] = p; if (p == minp[i]) { break; } } } }
constint N = 2e3; constint M = 1e7; //无向边需要开两倍 int cnt = 1; int head[N]; struct { int from; int to; int nex; }e[M]; voidadd(int u, int v){ cnt++; e[cnt].from = u; e[cnt].to = v; e[cnt].nex = head[u]; head[u] = cnt; }
voidsolve(){ int n; std::cin >> n; int need = 1;
for(int i = 1; i <= 2e3; i++){ int all = (i * (1 + i)) / 2; if(i % 2 == 0) all -= (i - 2) / 2; if(all + 1 >= n){ need = i; break; } }
int all = (need * (1 + need)) / 2; if(need % 2 == 0) all -= (need - 2) / 2;
std::vector<std::pair<int, int>> edge(1, {0, 0});
for(int i = 1; i <= need; i++){ for(int j = i; j <= need; j++){ if(need % 2 == 0 && i != 1 && i % 2 == 1 && j == i + 1){ continue; } edge.push_back({i, j}); add(i, j); add(j, i); } }
std::vector<int> ans; std::vector<int> use(cnt + 1, false); int t = 1; std::vector<int> res;
std::function<void(int)> dfs = [&](int node) -> void{ for(int now = head[node]; now > 0; now = head[node]){ if(use[now]){ head[node] = e[now].nex; continue; }