#include #include #include #include #include using namespace std; vector vec; set ss; int f(int p){ if(p==vec[p]){ return p; }else{ int p2=f(vec[p]); vec[p]=p2; return p2; } } int main() { // your code goes here int h,w; int ms[2][3001]; int cs[2][3001]; int c=0; memset(cs,0,sizeof(cs)); memset(ms,0,sizeof(ms)); scanf("%d %d",&h,&w); for(int y=0;y