Submission #1123364

#TimeUsernameProblemLanguageResultExecution timeMemory
1123364SharkyIsland Hopping (JOI24_island)C++17
65 / 100
4 ms424 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<pair<int, int>> e; for (int i = 1; i <= N; i++) { int lst = 0; for (int it = 1; it < N; it++) { int v = query(i, it); if (v > i) break; if (v < lst) break; lst = v; e.push_back({i, v}); } } sort(e.begin(), e.end(), [] (auto x, auto y) { if (x.second == y.second) return x.first < y.first; return x.second < y.second; }); for (auto& [x, y] : e) if (find(x) != find(y)) { merge(x, y); answer(x, y); } }
#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...