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 "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
ll paths[1501][1051];
ll N = 0;
ll cmp[1501];
ll find(ll a){
while (a != cmp[a]){
cmp[a] = cmp[cmp[a]];
a = cmp[a];
}
return a;
}
void unite(ll a, ll b){
ll A = find(a);
ll B = find(b);
cmp[A] = B;
FOR(i,0,1051){
paths[B][i] = paths[A][i] + paths[B][i];
paths[i][B] = paths[i][A] + paths[i][A];
}
// FOR(i,0,1051){
// paths[A][i] = 0;
// paths[i][A] = 0;
// }
}
void initialize(int n){
FOR(i,0,1501) cmp[i] = i;
FOR(i,0,n+1) FOR(j,0,n+1) paths[i][j] = 1;
}
int hasEdge(int u, int v){
ll U = find(u);
ll V = find(v);
paths[U][V]--;
paths[V][U]--;
if (paths[U][V] == 0){
unite(u, v);
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |