제출 #217692

#제출 시각아이디문제언어결과실행 시간메모리
217692VimmerNew Home (APIO18_new_home)C++14
0 / 100
5053 ms10304 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, q, k;

    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] = 0;

        ll mx = 0, kol = 0;

        for (ll i = 0; i < n; i++)
            if (g[i].F.S <= y && y <= g[i].S)
            {
                if (!mk[g[i].F.F.S]) {mk[g[i].F.F.S] = 1; kol++;}

                mx = max(mx, abs(x - g[i].F.F.F));
            }

        if (kol != k) {cout << -1 << endl; continue;}

        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...