This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Source: https://oj.uz/problem/view/JOI20_hamburg
//
#include "bits/stdc++.h"
using namespace std;
#define s second
#define f first
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<int> vi;
#define FOR(i, a, b) for (int i = (a); i<b; i++)
bool ckmin(int& a, int b){ return b < a ? a = b, true : false; }
bool ckmax(int& a, int b){ return b > a ? a = b, true : false; }
map<int, set<pii> > mp;
vector<vi> loc;
pii find() {
set<pii> prv = {{0, 0}};
int best = -1;
pii pos;
for (auto row: mp) {
set<pii> cur = {};
int pref = 0;
for (auto val: row.s) {
pref += val.s;
int here = (*prev(prv.upper_bound({val.f, -1}), 1)).s + pref;
cur.insert({val.f, here});
if (here > best) {
best = here;
pos={row.f, val.f};
}
}
prv = cur;
prv.insert({-1, 0});
}
return pos;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
FOR(i, 1, n + 1) {
int a, b, c, d;
cin >> a >> b >> c >> d;
loc.pb({a, b, c, d});
mp[a].insert({b, 1});
mp[a].insert({d + 1, -1});
mp[c+1].insert({b, -1});
mp[c+1].insert({d + 1, -1});
}
FOR(i, 0, k) {
pii best = find();
cout << best.f << ' ' << best.s << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |