Submission #734279

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7342792023-05-02 08:19:20mosiashvililukaMaking Friends on Joitter is Fun (JOI20_joitter2)C++14
100 / 100
786 ms71336 KiB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,t,tes,msh[100009],C,D;
long long pas;
vector <int> V[100009];
set <int> in[100009],out[100009],sm[100009];//sm-c ideashi in-ebia ogond komponentis magivrad wveros nomers agdeb
set <int>::iterator it,tt;
bool check(int q, int w){
if(out[w].find(q)==out[w].end()) return 0; else return 1;
}
void mrg(int Q, int W){
int q=msh[Q],w=msh[W];
if(q==w) return;
if(V[q].size()+in[q].size()+out[q].size()+sm[q].size()<V[w].size()+in[w].size()+out[w].size()+sm[w].size()) swap(q,w);
long long qw=V[q].size(),we=V[w].size(),Sq=sm[q].size(),Sw=sm[w].size();
pas-=qw*(qw-1);
pas-=we*(we-1);
pas-=qw*Sq;
pas-=we*Sw;
//
vector <pair <int, int> > NXT;
for(vector <int>::iterator IT=V[w].begin(); IT!=V[w].end(); IT++){
V[q].push_back((*IT));
tt=sm[q].find((*IT));
if(tt!=sm[q].end()){
sm[q].erase(tt);
}
msh[(*IT)]=q;
}
V[w].clear();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...