# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432016 | pauloamed | Nafta (COI15_nafta) | C++14 | 1114 ms | 311600 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>
using namespace std;
#define MP make_pair
#define pii pair<int,int>
#define ppiii pair<pii,int>
#define FF first.first
#define FS first.second
#define MAXN 2010
struct DSU{
vector<int> sizes, parents;
DSU(int n){
sizes = parents = vector<int>(n);
for(int i = 0; i < n; ++i){
sizes[i] = 1;
parents[i] = i;
}
}
int find(int current){
int newRoot = current; // variavel para guardar nova raiz
while(newRoot != parents[newRoot]) // enquanto nao encontro no raiz
newRoot = parents[newRoot]; // subo na arvore
// compressao de caminho (*) REMOVER SE FOR ROLLBACK
int next; // backup do pai
while(parents[current] != newRoot){ // enquanto nao acho a nova raiz
next = parents[current]; // faco o backup do pai
parents[current] = newRoot; // digo que o pai eh a raiz achada (*)
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |