第一题
并查集
#include<cstdio>
#include<iostream>
using namespace std;
const int maxn = 205;
int root[maxn];
int find(int x){
if(x == root[x]) return x;
int t = find(root[x]);
root[x] = t;
return t;
}
int main(){
int n, x;
cin>>n;
for(int i = 0; i < maxn; i++){
root[i] = i;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin >> x;
if(x >= 3){
int a = find(i);
int b = find(j);
if(a != b){
root[b] = a;
}
}
}
}
int cnt = 0;
for(int i = 0; i < n; i++){
if(root[i]==i) cnt++;
}
cout<<cnt<<endl;
return 0 ;
}