摘要:
大意:进行堆排序,输入n个数,输出前m小: #include <iostream> #include <algorithm> using namespace std; const int N = 100010; int n, m; int h[N], cnt; void down(int u) { 阅读全文
摘要:
#include <iostream> using namespace std; const int N = 50010; int n, m; int p[N], d[N]; int find(int x) { if (p[x] != x) { int t = find(p[x]); d[x] += 阅读全文
摘要:
给定一个包含 n 个点(编号为 1∼n)的无向图,初始时图中没有边。现在要进行 m个操作,操作共有三种:C a b,在点 a和点 b 之间连一条边,a 和 b可能相等;Q1 a b,询问点 a和点 b 是否在同一个连通块中,a 和 b可能相等;Q2 a,询问点 a所在连通块中点的数量;输入格式第一行 阅读全文