Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <string>
  3. #include <stack>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <iomanip>
  7. #include <fstream>
  8. #include <deque>
  9. #include <vector>
  10. #include <stdlib.h>
  11. #include <set>
  12. #include <queue>
  13. #include <iostream>
  14. #include <climits>
  15.  
  16.  
  17. using namespace std;
  18.  
  19.  
  20. int dfs(pair<int, int> v, vector <vector<char>>& mas, vector <vector<char>>& colors) {
  21.     if (mas[v.first][v.second] == '.' || colors[v.first][v.second] == 'B') {
  22.         return 0;
  23.     }
  24.      
  25.     colors[v.first][v.second] = 'B';
  26.  
  27.     return dfs(make_pair(v.first - 1, v.second), mas, colors) +
  28.         dfs(make_pair(v.first + 1, v.second), mas, colors) +
  29.         dfs(make_pair(v.first, v.second - 1), mas, colors) +
  30.         dfs(make_pair(v.first, v.second + 1), mas, colors) + 1;
  31. }
  32.  
  33. int main() {
  34.  
  35.     ifstream in("input.txt");
  36.     ofstream out("output.TXT");
  37.  
  38.     vector<vector<char>> vec(102, vector<char>(102, '.'));
  39.     vector<vector<char>> colors(102, vector<char>(102, 'W'));
  40.  
  41.     int n;
  42.     in >> n;
  43.  
  44.     for (int i = 0; i < n; i++) {
  45.         int x1, y1, x2, y2;
  46.         in >> x1 >> y1 >> x2 >> y2;
  47.         for (int u = y1; u < y2; u++) {
  48.             for (int v = x1; v < x2; v++) {
  49.                 vec[u + 1][v + 1] = '#';
  50.             }
  51.         }
  52.     }
  53.  
  54.     int maxS = 0;
  55.     for (int i = 1; i <= 100; i++) {
  56.         for (int j = 1; j <= 100; j++) {
  57.             if (vec[i][j] == '#' && colors[i][j] != 'B') {
  58.                 maxS = max(maxS, dfs(make_pair(i, j), vec, colors));
  59.             }
  60.         }
  61.     }
  62.  
  63.     out << maxS;
  64.  
  65.     //for (int i = 0; i < vec.size(); i++) {
  66.     //  for (int j = 0; j < vec.size(); j++) {
  67.     //      out << vec[i][j] << ' ';
  68.     //  }
  69.     //  out << endl;
  70.     //}
  71.  
  72.     out.close();
  73.     in.close();
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement