제출 #1123367

#제출 시각아이디문제언어결과실행 시간메모리
1123367SharkyIsland Hopping (JOI24_island)C++17
100 / 100
4 ms432 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] < N - 1) { 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...