Submission #217697

#TimeUsernameProblemLanguageResultExecution timeMemory
217697VimmerNew Home (APIO18_new_home)C++14
5 / 100
5066 ms10532 KiB
#include <bits/stdc++.h>

#define F first
#define S second
#define sz(x) ll(x.size())
#define N 100005
#define M ll(998244353)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef short int si;


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

    ll n, k, q;

    cin >> n >> k >> q;

    vector <pair <pair <pair <ll, ll>, ll>, ll> > g; g.resize(n);

    for (ll i = 0; i < n; i++) cin >> g[i].F.F.F >> g[i].F.F.S >> g[i].F.S >> g[i].S;

    for (;q > 0; q--)
    {
        ll x, y;

        cin >> x >> y;

        ll mk[k + 1];

        for (ll i = 0; i <= k; i++) mk[i] = 1e9;

        ll mx = 0;

        bool f = 1;

        for (ll i = 0; i < n; i++)
            if (g[i].F.S <= y && y <= g[i].S) mk[g[i].F.F.S] = min(mk[g[i].F.F.S], abs(x - g[i].F.F.F));

        for (int i = 1; i <= k; i++) if (mk[i] == 1e9) f = 0; else mx = max(mx, mk[i]);

        if (!f) cout << -1 << endl; else cout << mx << endl;
    }
}
#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...