제출 #1319542

#제출 시각아이디문제언어결과실행 시간메모리
1319542fateless새 집 (APIO18_new_home)C++20
5 / 100
5094 ms13024 KiB
// #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define now chrono::steady_clock::now().time_since_epoch().count() #define speedup cin.tie(0)->sync_with_stdio(0) #define bitcount(x) __builtin_popcountll(x) #define lla(x) x.rbegin(), x.rend() #define all(x) x.begin(), x.end() #define Tp template <class T> #define int long long #define pb push_back #define vc vector #define arr array const int inf = 1e18; inline void solve () { int n, k, q; cin >> n >> k >> q; vc<vc<arr<int, 3>>> tp (k + 1); for (int i = 1; i <= n; i++) { int x, t, a, b; cin >> x >> t >> a >> b; tp[t].pb({x, a, b}); } while (q--) { int id, t; cin >> id >> t; int ans = -1; for (int i = 1; i <= k; i++) { int res = inf; for (auto &[x, a, b] : tp[i]) if (a <= t && t <= b) res = min(res, abs(id - x)); ans = max(ans, res); } cout << (ans == inf? -1 : ans) << "\n"; } } signed main() { speedup; 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 */
#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...