# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
892074 | MilosMilutinovic | New Home (APIO18_new_home) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// todo
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
vector<int> x(n);
vector<int> t(n);
vector<int> a(n);
vector<int> b(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> t[i] >> a[i] >> b[i];
++b[i];
}
vector<int> l(q);
vector<int> y(q);
for (int i = 0; i < n; i++) {
cin >> l[i] >> y[i];
}
vector<int> xs;
for (int i = 0; i < n; i++) {
xs.push_back(a[i]);
xs.push_back(b[i]);
}
for (int i = 0; i < q; i++) {
xs.push_back(y[i]);
}
sort(xs.begin(), xs.end());
xs.erase(unique(xs.begin(), xs.end()), xs.end());
for (int i = 0; i < n; i++) {
a[i] = (int) (lower_bound(xs.begin(), xs.end(), a[i]) - xs.begin());
b[i] = (int) (lower_bound(xs.begin(), xs.end(), b[i]) - xs.begin());
}
for (int i = 0; i < q; i++) {
y[i] = (int) (lower_bound(xs.begin(), xs.end(), y[i]) - xs.begin());
}
int T = (int) xs.size();
vector<vector<int>> qs(T);
for (int i = 0; i < n; i++) {
qs[a[i]].push_back(i);
qs[b[i]].push_back(~i);
}
set<tuple<int, int, int>> open;
vector<array<int, 4>> ev;
vector<set<int>> my(k);
auto Insert = [&](int t, int x, int y) {
{
auto ptr = my[t].lower_bound(x);
if (ptr != my[t].begin() && ptr != my[t].end()) {
auto it = open.lower_bound({*prev(ptr), *ptr, -1});
ev.emplace_back(get<0>(*it), get<1>(*it), get<2>(*it), y);
open.erase(it);
}
if (ptr != my[t].end()) {
}
if (ptr != my[t].begin())
}
my[t].insert(x);
};
for (int i = 0; i < T; i++) {
for (int j : qs[i]) {
if (j >= 0) {
Insert(t[j], x[j], i);
} else {
j = ~j;
Remove(t[j], x[j], i);
}
}
}
return 0;
}