제출 #46537

#제출 시각아이디문제언어결과실행 시간메모리
46537RayaBurong25_1게임 (IOI14_game)C++17
100 / 100
618 ms160324 KiB
#include "game.h" #include <stdio.h> int Cut[1505][1505]; int P[1505], Sz[1505]; int N; int UF(int u) { return (P[u] == -1)?u:(P[u] = UF(P[u])); } void initialize(int n) { N = n; int i; for (i = 0; i < n; i++) { P[i] = -1; Sz[i] = 1; } } int hasEdge(int u, int v) { int pu = UF(u); int pv = UF(v); int i; // printf("Cut %d Sz %d %d\n", Cut[pu][pv], Sz[pu], Sz[pv]); if (Cut[pu][pv] + 1 == Sz[pu]*Sz[pv]) { P[pu] = pv; for (i = 0; i < N; i++) { Cut[pv][UF(i)] += Cut[pu][UF(i)]; Cut[pu][UF(i)] = 0; Cut[UF(i)][pv] = Cut[pv][UF(i)]; } Sz[pv] += Sz[pu]; return 1; } Cut[pu][pv]++; Cut[pv][pu]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...