/*
学习李大牛每天复习之前写过的算法,每天找一题出来做做复习;
*****并查集篇******
*/
这还算是一道简单的并查集,思路在代码中:
15MS | 340K |
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define x m*(i-1)+j
//define 实际上是字符替换,利用这一点将题中本应该是m*(i-1)+j的地方替换为x
//使得程序简洁
using namespace std;
char map[53][53];
struct squares
{
bool u;
bool d;
bool l;
bool r;
}s[11]; //存放 A-K 的田里渠道的方向
int f[3000];
int find(int a) //查找 父亲函数
{