Submission #1201629

#TimeUsernameProblemLanguageResultExecution timeMemory
1201629crispxx새 집 (APIO18_new_home)C++20
0 / 100
5093 ms10388 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() #define pb push_back #define ar array #define nl '\n' template <typename A, typename B> bool chmin(A &a, const B &b) { if(a > b) { return a = b, true; } return false; } template <typename A, typename B> bool chmax(A &a, const B &b) { if(a < b) { return a = b, true; } return false; } void solve() { int n, k, q; cin >> n >> k >> q; vector<int> x(n), t(n), a(n), b(n); for(int i = 0; i < n; i++) { cin >> x[i] >> t[i] >> a[i] >> b[i]; t[i]--; } // vector<int> mn(k), mx(k); // for(int i = 0; i < n; i++) { // } auto query = [&](int l, int y) -> int { vector<int> used(k); int ans = 0; for(int i = 0; i < n; i++) { if(y >= a[i] && y <= b[i]) { ans = max(ans, abs(l - x[i])); used[t[i]] = 1; } } for(int i = 0; i < k; i++) { if(!used[i]) return -1; } return ans; }; while(q--) { int l, y; cin >> l >> y; cout << query(l, y) << nl; } } /** 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 **/ signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); }
#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...