# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364651 | valerikk | Making Friends on Joitter is Fun (JOI20_joitter2) | C++17 | 1404 ms | 59884 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>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
int n, m;
ll res;
int p[N], sz[N];
set<int> out[N], in[N];
set<int> st[N];
int Find(int node) {
if(p[node] == node) return node;
p[node] = Find(p[node]);
return p[node];
}
void AddEdge(int a, int b) {
if(Find(a) == Find(b) || out[a].find(Find(b)) != out[a].end()) return;
//printf("Edge added: %d %d\n", a, Find(b));
out[a].insert(Find(b));
in[Find(b)].insert(a);
res += sz[Find(b)];
}
void RemoveEdge(int a, int b) {
//if(Find(a) == Find(b) || out[a].find(Find(b)) == out[a].end()) return;
//printf("Edge removed: %d %d\n", a, Find(b));
out[a].erase(Find(b));
in[Find(b)].erase(a);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |