版本比较
题解 LOJ2488 【「2018 集训队互测 Day 4」小修和小栋生♂成树】
正文
增加 4 行删除 4 行
9 行未改动1011121314141516171819202121222324252626272829303132333435363637383940116 行未改动全部展开9 行未改动typedef struct { int type; int root[307]; int loop[307];
inline void init(int n){ for (register int i = 1; i <= n; i++){ root[i] = i; loop[i] = 0; } }
int get_root(int x){ if (root[x] == x) return x; return root[x] = get_root(root[x]); }
inline void merge(int x, int y){ int x_root = get_root(x), y_root = get_root(y); if (x_root != y_root){ root[x_root] = y_root; loop[y_root] += loop[x_root]; } else { loop[x_root]++; } }
inline bool check(int x, int y){ int x_root = get_root(x), y_root = get_root(y); if (x_root != y_root) return loop[x_root] + loop[y_root] < type; return x_root != y_root || (type == 2 && loop[x_root] == 0);116 行未改动全部展开