제출 #654580

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6545802022-10-31 19:05:51atigunStranded Far From Home (BOI22_island)C++14
100 / 100
298 ms37996 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct dsu{
vector<int> parent;
vector<ll> sum;
vector<vector<int>> S;
int n;
dsu(int dsu_size) : n(dsu_size){
parent.resize(n+5);
iota(parent.begin(), parent.end(), 0);
sum.resize(n+5, 0);
S.resize(n+5);
}
int find(int v){
return parent[v] = (parent[v] == v ? v : find(parent[v]));
}
void merge(int v, int u){
if(S[find(u)].size() > S[find(v)].size())
swap(u, v);
if(find(u) == find(v))
return;
for(int x : S[find(u)])
S[find(v)].push_back(x);
S[find(u)].clear();
sum[find(v)]+= sum[find(u)];
parent[find(u)] = parent[find(v)];
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...