Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int w, h, a, b, n, ans = 0, x_ans, y_ans;
- vector<pair<int, bool>> events;
- vector<tuple<int, int, int, int>> all;
- void check(int u, int d, tuple<int, int, int, int> t) {
- auto [x1, y1, x2, y2] = t;
- if (y2 <= d || y1 >= u)
- return;
- events.emplace_back(x1, 1);
- events.emplace_back(x2, 0);
- }
- void upd(int i, int j) {
- auto [x1, y1, x2, y2] = all[i];
- auto [x3, y3, x4, y4] = all[j];
- int down = min(y2, y4);
- int up = max(y1, y3);
- if (up - down < b)
- return;
- for (int z = 0; z < n; z++) {
- if (z != i && z != j)
- check(up, down, all[z]);
- }
- int cur = 0, pos = -1;
- sort(events.begin(), events.end());
- for (int i = 0, last = -1; i < events.size(); i++) {
- if (events[i].second) {
- if (cur == 0 && ans < events[i].first - last) {
- ans = events[i].first - last;
- x_ans = last;
- y_ans = down;
- }
- cur++;
- }
- else
- cur--;
- last = events[i].first;
- }
- events.clear();
- }
- void Solve() {
- cin >> w >> h >> a >> b >> n;
- for (int i = 0, x1, y1, x2, y2; i < n; i++) {
- cin >> x1 >> y1 >> x2 >> y2;
- all.emplace_back(x1, y1, x2, y2);
- }
- all.emplace_back(-1, -1, 0, h + 1);
- all.emplace_back(-1, -1, w + 1, 0);
- all.emplace_back(-1, h, w + 1, h + 1);
- all.emplace_back(w, -1, w + 1, h + 1);
- n = all.size();
- for (int i = 0; i < n; i++)
- for (int j = i + 1; j < n; j++)
- upd(i, j);
- cout << x_ans << " " << y_ans << " " << x_ans + ans << " " << y_ans + b;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- Solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement