Submission #85983

#TimeUsernameProblemLanguageResultExecution timeMemory
85983fedoseevtimofeyNew Home (APIO18_new_home)C++14
0 / 100
5090 ms8932 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; struct store { int x, t, a, b; store(int x, int t, int a, int b) : x(x), t(t), a(a), b(b) {} }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, k, q; cin >> n >> k >> q; vector <store> kek; for (int i = 0; i < n; ++i) { int x, t, a, b; cin >> x >> t >> a >> b; --t; kek.emplace_back(x, t, a, b); } while (q--) { int l, y; cin >> l >> y; vector <int> mx(k, (int)1e9); for (auto s : kek) { if (s.a <= y && y <= s.b) { mx[s.t] = min(mx[s.t], abs(l - s.x)); } } int ans = 1e9; for (int i = 0; i < k; ++i) { ans = min(ans, mx[i]); } if (ans > 5e8) { cout << "-1\n"; } else { cout << ans << '\n'; } } }
#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...