제출 #953251

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
9532512024-03-25 18:04:31andrei_boaca조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++17
0 / 100
4 ms16988 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll n,m,ans;
ll comp[100005];
vector<ll> dsu[100005];
set<ll> par[100005];
set<pll> edgenod[100005];
set<ll> edgecomp[100005];
void dsu_merge(ll c1,ll c2)
{
ll nr1=(int)dsu[c1].size()+(int)par[c1].size()+(int)edgenod[c1].size();
ll nr2=(int)dsu[c2].size()+(int)par[c2].size()+(int)edgenod[c2].size();
if(nr1<nr2)
swap(c1,c2);
ll sz2=dsu[c2].size();
ll sz1=dsu[c1].size();
ll val=(ll)dsu[c1].size()*(ll)dsu[c2].size();
val=val*2LL;
ans+=val;
val=(ll)par[c1].size()*sz2;
ans+=val;
set<ll> why;
for(ll x:par[c2])
{
edgenod[comp[x]].erase({x,c2});
if(edgecomp[comp[x]].find(c2)!=edgecomp[comp[x]].end())
edgecomp[comp[x]].erase(c2);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...