Submission #1041486

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10414862024-08-02 04:43:52hotboy2703Making Friends on Joitter is Fun (JOI20_joitter2)C++17
100 / 100
532 ms102228 KiB
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll INF = 1e9;
const ll MAXN = 1e5+100;
set <ll> s[MAXN];
set <pll> rev[MAXN];
set <ll> edge[MAXN];
ll dsu[MAXN];
ll ans;
vector <pll> all;
void join(ll x,ll y){
x = dsu[x],y = dsu[y];
if (x==y)return;
if (sz(s[x]) < sz(s[y]))swap(x,y);
for (auto it = rev[x].lower_bound(MP(y,0));it != rev[x].end() && (*it).fi == y;it=rev[x].erase(it)){
ans -= sz(s[x]);
}
for (auto it = rev[y].lower_bound(MP(x,0));it != rev[y].end() && (*it).fi == x;it=rev[y].erase(it)){
ans -= sz(s[y]);
}
ans += sz(s[x]) * sz(s[y]) * 2;
ans += sz(rev[x]) * sz(s[y]) + sz(rev[y]) * sz(s[x]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...