# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
224199 | jamielim | Putovanje (COCI20_putovanje) | C++14 | 172 ms | 36340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;
const int MAXN = 200100;
int n;
struct UnionFind {
vector <int> v[MAXN];
int connected[MAXN],par[MAXN];
void init() {
for(int i=0;i<MAXN;i++){
v[i].clear();v[i].push_back(i);
par[i]=i;
connected[i]=0;
}
}
void merge(int a, int b) {
a = par[a];b = par[b];
if ((int)v[a].size() < (int)v[b].size()) swap(a, b); //merging smaller into larger
for (auto x : v[b]) {
if (par[x - 1] == a) connected[a]++;
if (par[x + 1] == a) connected[a]++;
v[a].push_back(x);
}
for (auto x : v[b]) par[x] = a;
connected[a] += connected[b];
}
int get(int x) { //number of times the edge from x to its parent (original tree) is used
컴파일 시 표준 에러 (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... |