Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <vector>#include <utility>using namespace std;#define N 1000bool region[N][N];pair<int, int> board[N][N];int dx[] = {-1, 0, 1, 0};int dy[] = {0, 1, 0, -1};int islands;pair<int, int> sfind(int x, int y){if (board[x][y].first == x && board[x][y].second == y)return make_pair(x, y);return board[x][y] = sfind(board[x][y].first, board[x][y].second);}bool sunion(int x1, int y1, int x2, int y2){auto p1 = sfind(x1, y1), p2 = sfind(x2, y2);if (p1 == p2)return false;board[p1.first][p1.second] = p2;return true;}void build(int x, int y)