Submission #1070810

#TimeUsernameProblemLanguageResultExecution timeMemory
1070810pawnedNew Home (APIO18_new_home)C++17
5 / 100
5069 ms16492 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const char nl = '\n';

void fastIO() {
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int main() {
	fastIO();
	int N, K, Q;
	cin>>N>>K>>Q;
	// stores of each type
	vector<pair<int, ii>> stores[K];
	// {pos, {start, end}}
	for (int i = 0; i < N; i++) {
		int x, y, a, b;
		cin>>x>>y>>a>>b;
		x--; y--;
		stores[y].pb({x, {a, b}});
	}
	for (int i = 0; i < Q; i++) {
		int x, t;
		cin>>x>>t;
		x--;
		vi nd(K, 1e9);
		for (int j = 0; j < K; j++) {
			for (pair<int, ii> p : stores[j]) {
				if (p.se.fi <= t && t <= p.se.se)
					nd[j] = min(nd[j], abs(p.fi - x));
			}
		}
		int ans = -1;
		for (int x : nd)
			ans = max(ans, x);
//		cout<<"ANSWER: ";
		if (ans != 1e9)
			cout<<ans<<endl;
		else
			cout<<-1<<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...