Submission #658765

# Submission time Handle Problem Language Result Execution time Memory
658765 2022-11-14T20:50:29 Z 600Mihnea New Home (APIO18_new_home) C++17
5 / 100
5000 ms 23292 KB
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

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 time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 4 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 5 ms 7380 KB Output is correct
6 Correct 5 ms 7392 KB Output is correct
7 Correct 5 ms 7380 KB Output is correct
8 Correct 6 ms 7380 KB Output is correct
9 Correct 5 ms 7384 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
11 Correct 5 ms 7380 KB Output is correct
12 Correct 5 ms 7388 KB Output is correct
13 Correct 5 ms 7380 KB Output is correct
14 Correct 4 ms 7404 KB Output is correct
15 Correct 5 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7392 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 5 ms 7300 KB Output is correct
20 Correct 5 ms 7392 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7388 KB Output is correct
25 Correct 5 ms 7364 KB Output is correct
26 Correct 5 ms 7392 KB Output is correct
27 Correct 5 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 5 ms 7380 KB Output is correct
30 Correct 6 ms 7508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 4 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 5 ms 7380 KB Output is correct
6 Correct 5 ms 7392 KB Output is correct
7 Correct 5 ms 7380 KB Output is correct
8 Correct 6 ms 7380 KB Output is correct
9 Correct 5 ms 7384 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
11 Correct 5 ms 7380 KB Output is correct
12 Correct 5 ms 7388 KB Output is correct
13 Correct 5 ms 7380 KB Output is correct
14 Correct 4 ms 7404 KB Output is correct
15 Correct 5 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7392 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 5 ms 7300 KB Output is correct
20 Correct 5 ms 7392 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7388 KB Output is correct
25 Correct 5 ms 7364 KB Output is correct
26 Correct 5 ms 7392 KB Output is correct
27 Correct 5 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 5 ms 7380 KB Output is correct
30 Correct 6 ms 7508 KB Output is correct
31 Execution timed out 5008 ms 11240 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5019 ms 23292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5025 ms 21684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 4 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 5 ms 7380 KB Output is correct
6 Correct 5 ms 7392 KB Output is correct
7 Correct 5 ms 7380 KB Output is correct
8 Correct 6 ms 7380 KB Output is correct
9 Correct 5 ms 7384 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
11 Correct 5 ms 7380 KB Output is correct
12 Correct 5 ms 7388 KB Output is correct
13 Correct 5 ms 7380 KB Output is correct
14 Correct 4 ms 7404 KB Output is correct
15 Correct 5 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7392 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 5 ms 7300 KB Output is correct
20 Correct 5 ms 7392 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7388 KB Output is correct
25 Correct 5 ms 7364 KB Output is correct
26 Correct 5 ms 7392 KB Output is correct
27 Correct 5 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 5 ms 7380 KB Output is correct
30 Correct 6 ms 7508 KB Output is correct
31 Execution timed out 5008 ms 11240 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 3 ms 7380 KB Output is correct
3 Correct 4 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 5 ms 7380 KB Output is correct
6 Correct 5 ms 7392 KB Output is correct
7 Correct 5 ms 7380 KB Output is correct
8 Correct 6 ms 7380 KB Output is correct
9 Correct 5 ms 7384 KB Output is correct
10 Correct 5 ms 7380 KB Output is correct
11 Correct 5 ms 7380 KB Output is correct
12 Correct 5 ms 7388 KB Output is correct
13 Correct 5 ms 7380 KB Output is correct
14 Correct 4 ms 7404 KB Output is correct
15 Correct 5 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7392 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 5 ms 7300 KB Output is correct
20 Correct 5 ms 7392 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7388 KB Output is correct
25 Correct 5 ms 7364 KB Output is correct
26 Correct 5 ms 7392 KB Output is correct
27 Correct 5 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 5 ms 7380 KB Output is correct
30 Correct 6 ms 7508 KB Output is correct
31 Execution timed out 5008 ms 11240 KB Time limit exceeded
32 Halted 0 ms 0 KB -