Submission #1240208

#TimeUsernameProblemLanguageResultExecution timeMemory
1240208rythm_of_knightIsland Hopping (JOI24_island)C++17
100 / 100
3 ms776 KiB
#include "island.h" #include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define ar array using namespace std; typedef long long ll; const int N = 303; int a[N][N], vis[N], f[N], sz[N], add[N]; int father(int x) { if (f[x] != f[f[x]]) return f[x] = father(f[x]); return f[x]; } void dsu(int u, int v) { u = father(u), v = father(v); if (u == v) return; if (sz[u] < sz[v]) swap(u, v); sz[u] += sz[v]; f[v] = u; } void solve(int n, int l) { for (int i = 1; i <= n; i++) f[i] = i, sz[i] = 1; int k = 1, cnt = 1; while (cnt < n) { int x = query(1, k); // cout << x << ' ' << flush; if (father(1) == father(x)) { k++; continue; } int t = 1, y, f = -1, c = -1; do { y = query(x, t); c++; if (f == -1) f = y; dsu(x, y); a[x][y] = a[y][x] = 1, cnt++, t++; } while (father(y) != father(1)); k++; } for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++) if (a[i][j]) answer(i, j); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...