# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068234 | epicci23 | Dango Maker (JOI18_dango_maker) | C++17 | 0 ms | 596 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"
//#define int long long
#define all(v) v.begin() , v.end()
//#define sz(a) (int)a.size()
using namespace std;
const int N = 205;
pair<int,int> par[N][N];
array<int,3> sz[N][N];
pair<int,int> find(int a,int b){
if(par[a][b]==make_pair(a,b)) return make_pair(a,b);
return par[a][b]=find(par[a][b].first,par[a][b].second);
}
void merge(int a,int b,int c,int d){
auto x=find(a,b);
auto y=find(c,d);
a=x.first,b=x.second,c=y.first,d=y.second;
if(make_pair(a,b)==make_pair(c,d)) return;
if(sz[a][b][0]+sz[a][b][1]+sz[a][b][2]<sz[c][d][0]+sz[c][d][1]+sz[c][d][2]){
swap(a,c);
swap(b,d);
}
par[c][d]=par[a][b];
for(int j=0;j<3;j++) sz[a][b][j]+=sz[c][d][j];
}
void _(){
int n,m;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |