Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <string>
- #include <stack>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #include <fstream>
- #include <deque>
- #include <vector>
- #include <stdlib.h>
- #include <set>
- #include <queue>
- #include <iostream>
- #include <climits>
- using namespace std;
- int dfs(pair<int, int> v, vector <vector<char>>& mas, vector <vector<char>>& colors) {
- if (mas[v.first][v.second] == '.' || colors[v.first][v.second] == 'B') {
- return 0;
- }
- colors[v.first][v.second] = 'B';
- return dfs(make_pair(v.first - 1, v.second), mas, colors) +
- dfs(make_pair(v.first + 1, v.second), mas, colors) +
- dfs(make_pair(v.first, v.second - 1), mas, colors) +
- dfs(make_pair(v.first, v.second + 1), mas, colors) + 1;
- }
- int main() {
- ifstream in("input.txt");
- ofstream out("output.TXT");
- vector<vector<char>> vec(102, vector<char>(102, '.'));
- vector<vector<char>> colors(102, vector<char>(102, 'W'));
- int n;
- in >> n;
- for (int i = 0; i < n; i++) {
- int x1, y1, x2, y2;
- in >> x1 >> y1 >> x2 >> y2;
- for (int u = y1; u < y2; u++) {
- for (int v = x1; v < x2; v++) {
- vec[u + 1][v + 1] = '#';
- }
- }
- }
- int maxS = 0;
- for (int i = 1; i <= 100; i++) {
- for (int j = 1; j <= 100; j++) {
- if (vec[i][j] == '#' && colors[i][j] != 'B') {
- maxS = max(maxS, dfs(make_pair(i, j), vec, colors));
- }
- }
- }
- out << maxS;
- //for (int i = 0; i < vec.size(); i++) {
- // for (int j = 0; j < vec.size(); j++) {
- // out << vec[i][j] << ' ';
- // }
- // out << endl;
- //}
- out.close();
- in.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement