Submission #1123366

#TimeUsernameProblemLanguageResultExecution timeMemory
1123366SharkyIsland Hopping (JOI24_island)C++17
57 / 100
4 ms428 KiB
#include "island.h" #include "bits/stdc++.h" using namespace std; int p[301]; int find(int u) { return p[u] == u ? u : p[u] = find(p[u]); } void merge(int u, int v) { p[find(v)] = find(u); } void solve(int N, int L) { for (int i = 1; i <= N; i++) p[i] = i; vector<int> mx(N+1, 0); vector<int> lst(N+1, 0); vector<int> cnt(N+1, 0); vector<int> vt[N+1]; vector<bool> ok(N+1, 1); for (int id = 1; id <= N; id++) { for (int i = 1; i <= N; i++) { if (!ok[i]) continue; while (mx[i] < id) { cnt[i]++; int v = query(i, cnt[i]); if (v > i || v < lst[i]) { ok[i] = 0; break; } lst[i] = v; mx[i] = v; vt[v].push_back(i); } } for (auto& x : vt[id]) { if (find(id) != find(x)) { merge(id, x); answer(id, x); } else ok[x] = 0; } } }
#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...