Submission #698660

#TimeUsernameProblemLanguageResultExecution timeMemory
698660vjudge1New Home (APIO18_new_home)C++17
5 / 100
5068 ms13144 KiB
#include <bits/stdc++.h> #include <array> #define all(v) (v.begin()), (v.end()) #define setall(a, val) for(auto& x : a) x = val #define ll long long clock_t start_time; double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; } void init() { #ifndef ONLINE_JUDGE FILE* _ = freopen("in.txt", "r", stdin); start_time = clock(); #endif } const ll MOD = 998244353; const ll N = 6e5 + 1; const ll M = 2e2 + 1; using namespace std; //#################################################################################### int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); //init(); int n, k, q; cin >> n >> k >> q; vector< vector< array<ll, 3> > > v(k + 1); for (int i = 0; i < n; i++) { ll x, t, a, b; cin >> x >> t >> a >> b; v[t].push_back({ x, a, b }); } while (q--) { ll x, y; cin >> x >> y; ll mx = 0; for (int i = 1; i <= k; i++) { ll mn = LLONG_MAX; for (array<ll, 3>& ar : v[i]) { if (ar[1] <= y && y <= ar[2]) mn = min(mn, abs(x - ar[0])); } if (mn == LLONG_MAX) mx = -1, i = k + 1; else mx = max(mx, mn); } cout << mx << endl; } cerr << get_time() << "s" << endl; }

Compilation message (stderr)

new_home.cpp: In function 'void init()':
new_home.cpp:10:8: warning: unused variable '_' [-Wunused-variable]
   10 |  FILE* _ = freopen("in.txt", "r", stdin);
      |        ^
#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...