#include <iostream> #include <vector> #include <cmath> #include <set> #include <string> #include <fstream> #include <algorithm> #include <map> #include <utility> #include <bitset> using ll = long long; struct Ter { ll x1, y1, x2, y2; }; std::ostream& operator<<(std::ostream& os, std::vector<ll> const& input) { for(auto const& i : input) os << i << ","; return os; } void brute_force(ll n, ll X, ll Y, std::vector<Ter> const& torus) { char area[X][Y][n]; for (int i = 0; i<n; ++i) { ll x1 = torus[i].x1; ll x2 = torus[i].x2; ll y1 = torus[i].y1; ll y2 = torus[i].y2; for (ll x = 0; x<X; ++x) { for (ll y = 0; y<Y; ++y) { if (y1 <= y && y < y2 && (x >= x2 || x < x1)) area[x][y][i] = 2; else if (y1 <= y && y < y2 && x1 <= x && x < x2) area[x][y][i] = 3; else if (x1 <= x && x < x2 && (y < y1 || y >= y2)) area[x][y][i] = 4; else area[x][y][i] = 1; } } } std::map<std::vector<char>, int> count; for (ll x = 0; x<X; ++x) { for (ll y = 0; y<Y; ++y) { std::vector<char> tmp(n,0); for (ll i = 0; i<n; ++i) { tmp[i] = area[x][y][i]; } if (count.count(tmp) > 0) count[tmp]++; else count[tmp] = 1; } } /* for (ll i = 0; i < n;++i){ for (ll y = Y-1; y>=0; y--) { for (ll x = 0; x<X; ++x) { std::cout << area[x][y][i]; } std::cout << std::endl; } std::cout << std::endl; } */ int maxValue = 0; ll suma = 0; for (auto const& [key, value] : count) { maxValue = std::max(value, maxValue); // std::cout << key << " " << value << std::endl; suma += value; } std::cout << maxValue << std::endl; } int main() { ll n, X,Y; std::vector<Ter> torus; std::cin >> n >> X >> Y; for (int i = 0; i<n; ++i) { ll x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; ll xs = std::min(x1, x2); ll xl = std::max(x1, x2); ll ys = std::min(y1, y2); ll yl = std::max(y1, y2); torus.push_back({xs, ys, xl, yl}); } brute_force(n, X, Y, torus); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #include <iostream> #include <vector> #include <cmath> #include <set> #include <string> #include <fstream> #include <algorithm> #include <map> #include <utility> #include <bitset> using ll = long long; struct Ter { ll x1, y1, x2, y2; }; std::ostream& operator<<(std::ostream& os, std::vector<ll> const& input) { for(auto const& i : input) os << i << ","; return os; } void brute_force(ll n, ll X, ll Y, std::vector<Ter> const& torus) { char area[X][Y][n]; for (int i = 0; i<n; ++i) { ll x1 = torus[i].x1; ll x2 = torus[i].x2; ll y1 = torus[i].y1; ll y2 = torus[i].y2; for (ll x = 0; x<X; ++x) { for (ll y = 0; y<Y; ++y) { if (y1 <= y && y < y2 && (x >= x2 || x < x1)) area[x][y][i] = 2; else if (y1 <= y && y < y2 && x1 <= x && x < x2) area[x][y][i] = 3; else if (x1 <= x && x < x2 && (y < y1 || y >= y2)) area[x][y][i] = 4; else area[x][y][i] = 1; } } } std::map<std::vector<char>, int> count; for (ll x = 0; x<X; ++x) { for (ll y = 0; y<Y; ++y) { std::vector<char> tmp(n,0); for (ll i = 0; i<n; ++i) { tmp[i] = area[x][y][i]; } if (count.count(tmp) > 0) count[tmp]++; else count[tmp] = 1; } } /* for (ll i = 0; i < n;++i){ for (ll y = Y-1; y>=0; y--) { for (ll x = 0; x<X; ++x) { std::cout << area[x][y][i]; } std::cout << std::endl; } std::cout << std::endl; } */ int maxValue = 0; ll suma = 0; for (auto const& [key, value] : count) { maxValue = std::max(value, maxValue); // std::cout << key << " " << value << std::endl; suma += value; } std::cout << maxValue << std::endl; } int main() { ll n, X,Y; std::vector<Ter> torus; std::cin >> n >> X >> Y; for (int i = 0; i<n; ++i) { ll x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; ll xs = std::min(x1, x2); ll xl = std::max(x1, x2); ll ys = std::min(y1, y2); ll yl = std::max(y1, y2); torus.push_back({xs, ys, xl, yl}); } brute_force(n, X, Y, torus); return 0; } |