Submission #226191

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2261912020-04-22 19:01:40MinnakhmetovMaking Friends on Joitter is Fun (JOI20_joitter2)C++14
0 / 100
5 ms512 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const int N = 1e5 + 5;
int w[N];
set<int> *members[N], *ingoing_ver[N], *outgoing_gr[N], *ingoing_gr[N];
ll ans = 0;
int n, m;
int find_set(int x) {
return w[x] < 0 ? x : w[x] = find_set(w[x]);
}
void mrg(int x, int y) {
x = find_set(x);
y = find_set(y);
if (x == y)
return;
ans -= members[x]->size() * (ll)(members[x]->size() - 1);
ans -= members[y]->size() * (ll)(members[y]->size() - 1);
ans -= ingoing_ver[x]->size() * (ll)members[x]->size();
ans -= ingoing_ver[y]->size() * (ll)members[y]->size();
if (members[x]->size() + ingoing_ver[x]->size() <
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...