Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Width, Height, lim;
- bool mat[100][100];
- int maxi = -1;
- void Process(int Y, int X) {
- mat[Y][X] = 1;
- if (X + 1 <= Width - 1)
- if (mat[Y][X + 1] == 0) {
- lim++;
- Process(Y, X + 1);
- }
- if (X - 1 >= 0)
- if (mat[Y][X - 1] == 0) {
- lim++;
- Process(Y, X - 1);
- }
- if (Y - 1 >= 0)
- if (mat[Y - 1][X] == 0) {
- lim++;
- Process(Y - 1, X);
- }
- if (Y + 1 <= Height - 1)
- if (mat[Y + 1][X] == 0) {
- lim++;
- Process(Y + 1, X);
- }
- }
- int main() {
- cin >> Width >> Height;
- for (int i = 0; i <= Height - 1; i++)
- for (int k = 0; k <= Width - 1; k++)
- cin >> mat[i][k];
- for (int i = 0; i <= Height - 1; i++)
- for (int k = 0; k <= Width - 1; k++) {
- if (mat[i][k] == 0) {
- lim = 1;
- Process(i, k);
- if (lim > maxi)
- maxi = lim;
- }
- }
- cout << maxi;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement