# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1109271 | dsyz | JOI tour (JOI24_joitour) | C++17 | 160 ms | 26556 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 "joitour.h"
using namespace std;
using ll = long long;
#define MAXN (200005)
ll N, Q;
ll type[MAXN];
vector<ll> v[MAXN];
ll parent[MAXN];
ll JJ[MAXN], OO[MAXN], II[MAXN];
ll jtot = 0, otot = 0, itot = 0;
ll find_set(ll x){
if(parent[x] == x) return x;
parent[x] = find_set(parent[x]);
return parent[x];
}
bool same_set(ll x,ll y){
return find_set(x) == find_set(y);
}
void merge_set(ll x,ll y){
if(same_set(x,y)) return;
ll totalJJ = JJ[find_set(x)] + JJ[find_set(y)];
ll totalOO = OO[find_set(x)] + OO[find_set(y)];
ll totalII = II[find_set(x)] + II[find_set(y)];
parent[find_set(x)] = find_set(y);
ll newroot = find_set(x);
JJ[newroot] = totalJJ;
OO[newroot] = totalOO;
II[newroot] = totalII;
}
# | 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... |