| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332439 | 2sqrt3 | Island Hopping (JOI24_island) | C++20 | 2 ms | 412 KiB |
#include "island.h"
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
struct DSU {
vector<int> f;
DSU(int n) {
f.resize(n + 1);
iota(f.begin(), f.end(), 0);
}
int find(int x) {
return f[x] == x ? x : f[x] = find(f[x]);
}
void unite(int x, int y) {
x = find(x); y = find(y);
if (x != y) f[x] = y;
}
};
void solve(int N, int L) {
DSU dsu(N);
vector<int> count(N + 1, 1);
vector<bool> vis(N + 1, false);
vis[1] = true;
for (int i = 2; i <= N; ++i) {
if (vis[dsu.find(i)]) continue;
vector<int> path;
int curr = i;
while (!vis[dsu.find(curr)]) {
path.push_back(curr);
int v = query(curr, count[curr]);
bool in_path = false;
for(int p : path) if(p == v) { in_path = true; break; }
if (in_path) {
count[curr]++;
} else {
if (vis[dsu.find(v)]) {
int last = v;
while (!path.empty()) {
int node = path.back();
path.pop_back();
answer(node, last);
dsu.unite(node, last);
vis[node] = true;
last = node;
}
break;
} else {
curr = v;
}
}
}
}
}| # | 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... | ||||
