#include <algorithm> #include <iostream> #include <unordered_map> #include <utility> #include <vector> using hash_t = unsigned long long; hash_t hash64(hash_t x) { x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9uLL; x = (x ^ (x >> 27)) * 0x94D049BB133111EBuLL; return x ^ (x >> 31); } int solve(const std::vector<std::pair<int, hash_t>>& v) { std::unordered_map<hash_t, int> r; hash_t c = 0; int prev_x = 0; for (const auto& [x, h] : v) { r[c] += x - prev_x; prev_x = x; c ^= h; } return std::max_element(r.begin(), r.end(), [](const auto& lhs, const auto& rhs) { return lhs.second < rhs.second; })->second; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, w, h; std::cin >> n >> w >> h; std::vector<std::pair<int, hash_t>> x(n * 2 + 2), y(n * 2 + 2); x[0] = {0, 0}; x[1] = {w, 0}; y[0] = {0, 0}; y[1] = {h, 0}; for (int i = 1; i <= n; i++) { int x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; hash_t h = hash64(i); x[i << 1 | 0] = {x1, h}; x[i << 1 | 1] = {x2, h}; y[i << 1 | 0] = {y1, h}; y[i << 1 | 1] = {y2, h}; } std::sort(x.begin(), x.end()); std::sort(y.begin(), y.end()); std::cout << (long long)solve(x) * solve(y) << '\n'; 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 | #include <algorithm> #include <iostream> #include <unordered_map> #include <utility> #include <vector> using hash_t = unsigned long long; hash_t hash64(hash_t x) { x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9uLL; x = (x ^ (x >> 27)) * 0x94D049BB133111EBuLL; return x ^ (x >> 31); } int solve(const std::vector<std::pair<int, hash_t>>& v) { std::unordered_map<hash_t, int> r; hash_t c = 0; int prev_x = 0; for (const auto& [x, h] : v) { r[c] += x - prev_x; prev_x = x; c ^= h; } return std::max_element(r.begin(), r.end(), [](const auto& lhs, const auto& rhs) { return lhs.second < rhs.second; })->second; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, w, h; std::cin >> n >> w >> h; std::vector<std::pair<int, hash_t>> x(n * 2 + 2), y(n * 2 + 2); x[0] = {0, 0}; x[1] = {w, 0}; y[0] = {0, 0}; y[1] = {h, 0}; for (int i = 1; i <= n; i++) { int x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; hash_t h = hash64(i); x[i << 1 | 0] = {x1, h}; x[i << 1 | 1] = {x2, h}; y[i << 1 | 0] = {y1, h}; y[i << 1 | 1] = {y2, h}; } std::sort(x.begin(), x.end()); std::sort(y.begin(), y.end()); std::cout << (long long)solve(x) * solve(y) << '\n'; return 0; } |