Submission #710010

#TimeUsernameProblemLanguageResultExecution timeMemory
710010vjudge1New Home (APIO18_new_home)C++17
0 / 100
5025 ms13844 KiB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 3e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;

array<int, 4> a[N];
array<int, 3> qu[N];
int dist[N];

void solve()
{
    int n, k, q; cin >> n >> k >> q;
    
    for(int i = 1; i <= n; ++i){
        int x, t, l, r; cin >> x >> t >> l >> r;
        a[i] = {x, t, l, r};
    }

    for(int i = 1; i <= q; ++i){
        int l, y; cin >> l >> y;
        
        for(int j = 1; j <= k; ++j){
            dist[j] = MAXA;
        }
        for(int i = 1; i <= n; ++i){
            int x = a[i][0], t = a[i][1], l = a[i][2], r = a[i][3];
            if (l <= y && y <= r){
                dist[t] = min(dist[t], abs(x - l));
            }
        }
        int ans = 0;
        for(int j = 1; j <= k; ++j){
            ans = max(ans, dist[j]);
        }
        if (ans == MAXA) ans = -1;

        cout << ans << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // freopen("codeforces.inp","r",stdin);
    // freopen("codeforces.out","w",stdout);

    int t = 1; // cin >> t;
    while (t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...