# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806589 | Trisanu_Das | Werewolf (IOI18_werewolf) | C++17 | 629 ms | 158876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
#define vi vector<int>
const int mx = 6e5 + 5;
int par[mx], tin[mx], tout[mx], ti, id; vector<int> dsuAdj[mx]; set<int> nodes[mx];
int get(int i){
return i == par[i] ? i : par[i] = get(par[i]);
}
void merge(int a, int b, bool build){
a = get(a); b = get(b); if (a == b) return;
if (build){
dsuAdj[id].push_back(a); dsuAdj[id].push_back(b);
par[a] = par[b] = id++;
}
else{
if (nodes[a].size() > nodes[b].size()) swap(a, b);
par[a] = b;
nodes[b].insert(nodes[a].begin(), nodes[a].end());
}
}
void dfs(int i){
tin[i] = ti++;
for (int x : dsuAdj[i]) dfs(x);
tout[i] = ti - 1;
}
# | 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... |