Line 75: Char 17: error: use of undeclared identifier 'Solution'
int ret = Solution().findCircleNum(param_1); return ret;
^
‘’‘
class UnionFind {
public:
UnionFind (int sz): root(sz), rank(sz){
for (int i=1;i<=sz;i++){
root[i]=i;
rank[i]=1;
}
}
int Find(int x){
while (x!=root[x]){
x=root[x];
}
return x;
}
void Set(int x,int y){
int X=Find(x),Y=Find(y);
if (X!=Y){
if (rank[x]>rank[y])
root[Y]=X;
else if (rank[x]<rank[y])
root[X]=Y;
else{
root[Y]=X;
rank[X]++;
}
}
}
bool connect(int x,int y){
return root[x]==root[y];
}
private:
vector root;
vector rank;
};
int main() {
char c;
int i,j=1;
int n=2005,ans=0;
int province[2005]={0};
UnionFind city(n);
while (cin>>c) if (c=='[') break;
do{
i=0;
while (cin>>c){
if (c==']') break;
if (c=='1'){
i++;
city.Set(i,j);
}
else if (c=='0') i++;
}
j++;n=i;
}while(j<n);
for (int i=1;i<=n;i++){
if (!province[city.Find(i)]){
ans++;
province[city.Find(i)]=1;
}
}
cout<<ans;
return 0;}
’‘’