分男女加上N即可
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAX_N 5000
using namespace std;
int Unions[MAX_N];
int N,Q,X,Y;
int Find(int i ) {
return Unions[i] == i ? Unions[i] : Unions[i] = Find(Unions[i]);
}
void Union(int i,int j) {
i = Find(i); j = Find(j);
Unions[i] = j;
}
void init() {
for (int i = 0 ;i <= N << 1 ;i++) {
Unions[i] = i;
}
}
int main()
{
ios::sync_with_stdio(false);
int test; cin >> test;
int cnt = 1;
while (test--) {
cin >> N >> Q;
init();
bool has_bug = false;
for (int i = 0;i < Q;i++) {
cin >> X >> Y;
if (!has_bug) {
if (Find(X) != Find(Y) && Find(X + N ) != Find(Y + N)) {
Union(X,Y + N);
Union(Y,X + N);
} else{
has_bug = true;
}
}
}
cout << "Scenario #" << cnt++ <<":" << endl;
if (has_bug) {
cout << "Suspicious bugs found!" << endl;
} else {
cout << "No suspicious bugs found!" << endl;
}
cout <<endl;
}
return 0;
}