就是一个dfs查找星座,然后再数出星系数。
函数:
#include <bits/stdc++.h>
using namespace std;
int n,m,maxn,maxnr,fx[8]={
0,0,-1,1,-1, 1,-1,1},
fy[8]={
-1,1,-1,1, 1,-1, 0,0};
int a[1539][1539],b[900001]={
0};
inline void read(register int &x){
x=0;register int f=1;register char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=g