Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <fstream>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include <math.h>
- #include <cmath>
- #include <string>
- #include <set>
- #include <deque>
- #include <cctype>
- #include <iomanip>
- #include <stdlib.h>
- #include <queue>
- using namespace std;
- enum Color
- {
- WHITE,
- BLACK
- };
- void dfs(int x, int y, vector <vector<char>>& field, vector <vector<Color>>& colors)
- {
- colors[x][y] = BLACK;
- if (field[x + 1][y] == '#' && colors[x + 1][y] == WHITE)
- {
- dfs(x + 1, y, field, colors);
- }
- if (field[x - 1][y] == '#' && colors[x - 1][y] == WHITE)
- {
- dfs(x - 1, y, field, colors);
- }
- if (field[x][y + 1] == '#' && colors[x][y + 1] == WHITE)
- {
- dfs(x, y + 1, field, colors);
- }
- if (field[x][y - 1] == '#' && colors[x][y - 1] == WHITE)
- {
- dfs(x, y - 1, field, colors);
- }
- }
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- int n, ans = -10000000;
- in >> n;
- vector <vector <char>> field (100 + 2, vector <char> (100 + 2, '@'));
- vector <vector <Color>> colors (100 + 2, vector <Color> (100 + 2, WHITE));
- for (int i = 1; i <= 100; i++)
- {
- for (int j = 1; j <= 100; j++)
- {
- field[i][j] = '.';
- }
- }
- for (int i = 1; i <= n; i++)
- {
- int xS, yS, xE, yE;
- in >> xS >> yS >> xE >> yE;
- for (int j = xS; j <= xE; j++)
- {
- for (int k = yS; k <= yE; k++)
- {
- field[j][k] = '#';
- }
- }
- }
- for (int i = 1; i <= 100; i++)
- {
- for (int j = 1; j <= 100; j++)
- {
- if (field[i][j] == '#' && colors[i][j] == WHITE)
- {
- dfs(i, j, field, colors);
- }
- }
- }
- out << ans;
- out.close();
- in.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement