This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
using namespace std;
const int N = 1e8 + 10, mod = 1e9 + 7;
int n, k, q;
vector<int> x, a , b, type;
signed main()
{
FAST;
cin >> n >> k >> q;
for(int i = 0; i < n; i++) {
int time, t, x1, y1;
cin >> time >> t >> x1 >> y1;
x.push_back(time);
a.push_back(x1);
b.push_back(y1);
type.push_back(t);
}
while(q--) {
int l, y;
cin >> y >> l;
vector<int> v;
bool vis[k+1];
for(int i = 1; i <= k; i++) vis[i] = 0;
for(int i = 0; i < n; i++) {
if(a[i] <= l && b[i] >= l) {
v.push_back(x[i]);
vis[type[i]] = 1;
}
}
bool ans = 1;
for(int i = 1; i <= k; i++) if(vis[i] == 0) ans = 0;
if(!ans) cout << -1 << endl;
else {
sort(all(v));
// cout << v[0] << ' ' << v[v.size() - 1] << ' ' << y << endl;
cout << max(abs(v[0] - y), abs(v[v.size() - 1] - y)) << 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... |