#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |