Submission #516791

#TimeUsernameProblemLanguageResultExecution timeMemory
516791pragmatistNew Home (APIO18_new_home)C++17
5 / 100
5056 ms27888 KiB
#include <bits/stdc++.h> #define sz(v) v.size() #define pb push_back #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define x first #define y second #define int long long #define nl "\n" using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair <ll, ll> pii; const int N = (int)3e5 + 7; const int M = (int)15e6 + 7; const ll MOD = (ll)1e9 + 7; const int inf = (ll)1e9 + 7; const ll INF = (ll)3e18 + 7; pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; int n, q, k, x[N], a[N], b[N], t[N]; vector<pair<int, pii> > g[N]; void solve() { cin >> n >> k >> q; for(int i = 1; i <= n; ++i) { cin >> x[i] >> t[i] >> a[i] >> b[i]; g[t[i]].pb({x[i], {a[i], b[i]}}); } while(q--) { int l, x; cin >> l >> x; int ans = -1; for(int i = 1; i <= k; ++i) { int cur = inf; for(auto e : g[i]) { int p = e.x, L = e.y.x, R = e.y.y; if(x >= L && x <= R) cur = min(cur, abs(p - l)); } ans = max(ans, cur); } cout << (ans == inf ? -1 : ans) << nl; } } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int test = 1; //cin >> test; for(int i = 1; i <= test; ++i) { //cout << "Case " << i << ": "; solve(); } return 0; } /* 4 2 4 3 1 1 10 9 2 2 4 7 2 5 7 4 1 8 10 5 3 5 6 5 9 1 10 */ /* 2 1 3 1 1 1 4 1 1 2 6 1 3 1 5 1 7 */ /* 1 1 1 100000000 1 1 1 1 1 1 */
#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...