Submission #658765

#TimeUsernameProblemLanguageResultExecution timeMemory
658765600MihneaNew Home (APIO18_new_home)C++17
5 / 100
5025 ms23292 KiB
bool home = 0; #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = (int) 3e5 + 7; const int INF = (int) 1e9 + 7; int n; int k; int q; struct T { int x; int t; int a; int b; }; T v[N]; vector<int> gs[N]; int main() { if (home == 0) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } else { freopen ("input.txt", "r", stdin); } cin >> n >> k >> q; for (int i = 1; i <= n; i++) { cin >> v[i].x >> v[i].t >> v[i].a >> v[i].b; gs[v[i].t].push_back(i); } for (int iq = 1; iq <= q; iq++) { int x, t; cin >> x >> t; int sol = -INF; for (int tp = 1; tp <= k; tp++) { int nr = INF; for (auto &i : gs[tp]) { if (v[i].a <= t && t <= v[i].b) { nr = min(nr, abs(x - v[i].x)); } } sol = max(sol, nr); } if (sol == INF) { sol = -1; } cout << sol << "\n"; } return 0; }

Compilation message (stderr)

new_home.cpp: In function 'int main()':
new_home.cpp:28:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen ("input.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...