At the beginning, I didn't know what the meaning of the question was. What is the difference between the late feedback and the later feedback?
I am not very familiar with the third group of data. Why can't I use a 312,132 combination?
Later, I found that this is a question of the test and query set Qaq.
Angry post code:
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <math.h> 5 #include <iostream> 6 #include <algorithm> 7 using namespace std; 8 9 const int INF = 0x3f3f3f3f;10 11 int n, m, fa[100], x, y;12 13 int gf(int x) {14 if (fa[x] != x) fa[x] = gf(fa[x]);15 return fa[x];16 }17 18 int main() {19 scanf("%d%d", &n, &m);20 for (int i = 1; i <= n; i++) fa[i] = i;21 while (m--) {22 scanf("%d%d", &x, &y);23 fa[gf(x)] = gf(y);24 }25 long long ans = (1LL << n);26 for (int i = 1; i <= n; i++)27 if (gf(i) == i) ans /= 2;28 printf("%I64d\n", ans);29 }