Submission #1067594

#TimeUsernameProblemLanguageResultExecution timeMemory
1067594beaconmcGame (IOI14_game)C++14
42 / 100
200 ms25424 KiB
#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[1502][1502];
ll N = 0;

ll cmp[1502];

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,1052){
        paths[B][i] += paths[A][i];
        paths[i][B] += paths[A][i];
    }

}

void initialize(int n){
    FOR(i,0,1502) cmp[i] = i;
    FOR(i,0,1502) FOR(j,0,1502) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...