正文
增加 3 行删除 3 行
12 行未改动13141516171819202122232425262728293 行未改动33343536373839404115 行未改动12 行未改动using namespace std;const int N = 2e3 + 5, M = 4e6 + 5;int T, n, m, fa[N], sum;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;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;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 行未改动12 行未改动13141516171819202122232425262728293 行未改动33343536373839404115 行未改动12 行未改动using namespace std;const int N = 2e3 + 5, M = 4e6 + 5;int T, n, m, fa[N], sum;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;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;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 行未改动