제출 #1067587

#제출 시각아이디문제언어결과실행 시간메모리
1067587beaconmc게임 (IOI14_game)C++14
0 / 100
2 ms12840 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][1052]; 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[B][i]; paths[i][B] = paths[A][i] + paths[B][i]; } FOR(i,0,1052){ paths[A][i] = 0; paths[i][A] = 0; } } void initialize(int n){ FOR(i,0,1502) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...