# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658765 | 600Mihnea | New Home (APIO18_new_home) | C++17 | 5025 ms | 23292 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.
bool home = 0;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (int) 3e5 + 7;
const int INF = (int) 1e9 + 7;
int n;
int k;
int q;
struct T {
int x;
int t;
int a;
int b;
};
T v[N];
vector<int> gs[N];
int main() {
if (home == 0) {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
} else {
freopen ("input.txt", "r", stdin);
}
cin >> n >> k >> q;
for (int i = 1; i <= n; i++) {
cin >> v[i].x >> v[i].t >> v[i].a >> v[i].b;
gs[v[i].t].push_back(i);
}
for (int iq = 1; iq <= q; iq++) {
int x, t;
cin >> x >> t;
int sol = -INF;
for (int tp = 1; tp <= k; tp++) {
int nr = INF;
for (auto &i : gs[tp]) {
if (v[i].a <= t && t <= v[i].b) {
nr = min(nr, abs(x - v[i].x));
}
}
sol = max(sol, nr);
}
if (sol == INF) {
sol = -1;
}
cout << sol << "\n";
}
return 0;
}
Compilation message (stderr)
# | 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... |