版本比较
题解:CF1054G New Road Network
正文
增加 3 行删除 3 行
12 行未改动131415161717181920212223242525262728293 行未改动3334353637373839404115 行未改动12 行未改动using namespace std;
const int N = 2e3 + 5, M = 4e6 + 5;int T, n, m, fa[N], sum;bitset<N> bs[N]; bitset<N> bs[N];char s[N];struct edge{ int x, y, w;}e[M], output[N];
inline int find(int u) {return fa[u] == u ? u : fa[u] = find(fa[u]);}signed main(){ cin >> T; cin >> T; while(T--){ scanf("%d%d", &n, &m); sum = 0; for(int i = 1; i <= n; ++i) bs[i].reset(), fa[i] = i;3 行未改动 for(int j = 1; j <= n; ++j) if(s[j] == '1') bs[j].set(i), ++sbnjc; sum += max(0, sbnjc - 1); } int tot = 0, tt = 0; int tot = 0, tt = 0; for(int i = 1; i <= n; ++i) for(int j = i + 1; j <= n; ++j) e[++tot] = {i, j, (bs[i] & bs[j]).count()}; sort(e + 1, e + 1 + tot, [](edge A, edge B){return A.w > B.w;});15 行未改动