Submission #850467

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8504672023-09-16 15:21:03MinaRagy06Stranded Far From Home (BOI22_island)C++17
25 / 100
1045 ms524288 KiB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int N = 200'005;
int par[N], sz[N], bad[N];
ll cnt[N], a[N];
vector<int> adj[N];
pair<int, int> find(int u) {
if (par[u] == u) {
return {u, bad[u]};
}
pair<int, int> v = find(par[u]);
bad[u] |= v.second;
par[u] = v.first;
return {par[u], bad[u]};
}
void join(int u, int v) {
u = find(u).first, v = find(v).first;
if (u == v) return;
par[v] = u, sz[u] += sz[v], cnt[u] += cnt[v];
for (auto nxt : adj[v]) {
int x = find(nxt).first;
if (x != u) {
adj[u].push_back(nxt);
}
}
adj[v].clear();
}
int main() {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...