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>
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const int N = 200005;
vector<pair<pair<int, int>, pair<int, int>>> v;
vector<pair<int, int>> aa;
void solve()
{
int n, i, j, k, q, x, y, t, a, b;
cin >> n >> k >> q;
for (i = 0; i < n; i++)
{
cin >> x >> t >> a >> b;
v.push_back({ {a, b}, {x, t} });
}
for ( i = 0; i < q; i++)
{
cin >> x >> y;
map<int, int> ma;
map<int, int> ma1;
for ( j = 0; j < n; j++)
{
if (v[j].first.first <= y && v[j].first.second >= y)
{
if (ma[v[j].second.second] == 0)
{
ma[v[j].second.second] = 1;
ma1[v[j].second.second] = abs(x - v[j].second.first);
}
else
{
ma1[v[j].second.second] = min(ma1[v[j].second.second], abs(x - v[j].second.first));
}
}
}
if (ma.size() == k)
{
int ans = 0;
for (auto to : ma1)
{
ans = max(ans, to.second);
}
cout << ans << '\n';
}
else
{
cout << -1 << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
new_home.cpp: In function 'void solve()':
new_home.cpp:60:23: warning: comparison of integer expressions of different signedness: 'std::map<int, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | if (ma.size() == k)
| ~~~~~~~~~~^~~~
# | 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... |