vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; }
int res = -1; for (int i = 0; i < n; i++) { bool ok = true; for (int j = 0; j < n; j++) { if (j == i) continue; if (abs(a[i] - a[j]) % k == 0) { ok = false; } } if (ok) { res = i; } }
#include<bits/stdc++.h> usingnamespace std; using ll = longlong;
intmain(){ int t; cin >> t;
while (t--) { ll n, k; cin >> n >> k;
if (n < 60 && (1LL << n - 1) < k) { cout << -1 << endl; } else { k--; vector<int> res(n); int l = 0, r = n - 1; for (int bit = n - 1; bit >= 0; bit--) { if (bit >= 60 || k < (1LL << bit - 1)) { res[l++] = n - bit; } else { res[r--] = n - bit; k -= 1LL << bit - 1; } } for (auto x : res) { cout << x << " "; } cout << endl; } }
vector<vector<int>> E(n); for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; u--, v--; E[u].push_back(v); E[v].push_back(u); }
vector<int> w(n); int now = 0; auto dfs = [&](thisauto&& self, int u, int p) -> void { int fst = 1; for (auto v : E[u]) { if (v == p) continue; if (fst) { now = w[v] = (w[u] + 1); fst = 0; } else { int res = now - w[u] + 2; if (res < 4) res = 4; elseif (res & 1) res++; now = w[v] = (w[u] + res); } self(v, u); } }; now = w[0] = 1; dfs(0, -1);
for (int i = 0; i < n; i++) { cout << w[i] << " "; } cout << endl; }