제출 #1159526

#제출 시각아이디문제언어결과실행 시간메모리
1159526user3새 집 (APIO18_new_home)C++20
0 / 100
5093 ms9832 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define mp make_pair #define pb push_back #define pf push_front #define inf 100000000000000000 #define ff first #define ss second #define pii pair<int,int> #define mod 998244353 #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define osetp tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> #define one(x) __builtin_popcount(x) #define fone(x) __builtin_clz(n) #define fraction(x) cout<<setprecision(x)<<fixed const int d8i[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const int d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int d4i[4] = {1, 0, -1, 0}; const int d4j[4] = {0, 1, 0, -1}; const int mxn = 1e5; void solve( ) { int n, k, q; cin >> n >> k >> q; vector<array<int, 4>>a(n); for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3]; } while (q--) { int ans = -1; int l, y; cin >> l >> y; map<int, int>s; for (int i = 0; i < n; i++) { if (a[i][2] <= y and y <= a[i][3]) { if (s.find(a[i][2]) == s.end()) { s[a[i][2]] = abs(l - a[i][0]); } else { s[a[i][2]] = min(abs(a[i][2] - l), s[a[i][2]]); } } } if (sz(s) != k) { cout << -1 << '\n'; continue; } cout << ans << '\n'; } } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; for (int i = 1; i <= t; i++) { 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...