Submission #264836

#TimeUsernameProblemLanguageResultExecution timeMemory
264836extraterrestrial새 집 (APIO18_new_home)C++14
0 / 100
5057 ms18696 KiB
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back  
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll    

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> x(n), type(n), l(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> type[i] >> l[i] >> r[i];
    type[i]--;
  }
  vector<int> best(k);
  for (int i = 0; i < q; i++) {
    int pos, tt;
    cin >> pos >> tt;
    fill(all(best), 1e9);
    for (int j = 0; j < n; j++) {
      if (tt >= l[j] && tt <= r[j]) {
        best[type[j]] = min(best[type[j]], abs(pos - x[i]));
      }
    }
    int rez = 0;
    for (int j = 0; j < k; j++) {
      rez = max(rez, best[j]);
    }
    if (rez == 1e9) {
      cout << -1 << '\n';
    }
    else {
      cout << rez << '\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...