3
vector<vector<int>> nbrs = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};4
pair<int, int> dfs(vector<vector<int>> &land, int i, int j, vector<vector<bool>> &visited) {6
pair<int, int> res = make_pair(i, j);7
for (auto &nbr : nbrs) {10
if (x < 0 || y < 0 || x >= land.size() || y >= land[0].size() || visited[x][y] ||13
pair<int, int> ans = dfs(land, x, y, visited);14
res.first = max(res.first, ans.first);15
res.second = max(res.second, ans.second);19
vector<vector<int>> findFarmland(vector<vector<int>> &land) {21
int n = land[0].size();22
vector<vector<bool>> visited(m, vector<bool>(n, false));23
vector<vector<int>> ans;24
for (int i = 0; i < m; i++) {25
for (int j = 0; j < n; j++) {26
if (!visited[i][j] && land[i][j] == 1) {27
pair<int, int> p = dfs(land, i, j, visited);31
res.push_back(p.first);32
res.push_back(p.second);