Submission #701452

# Submission time Handle Problem Language Result Execution time Memory
701452 2023-02-21T08:55:35 Z Abrar_Al_Samit New Home (APIO18_new_home) C++17
12 / 100
5000 ms 37204 KB
#include<bits/stdc++.h>
using namespace std;

const int nax = 6e4 + 10;

int l[nax];
int x[nax], t[nax];
int pos[nax];
multiset<int>live[nax];
int ans[nax];
void PlayGround() {
  int n, q, k;
  cin>>n>>k>>q;

  vector<int>imp;
  map<int, vector<int>>query, shopin, shopout;

  for(int i=0; i<n; ++i) {
    cin>>x[i]>>t[i];

    int a, b;
    cin>>a>>b;
    shopin[a].push_back(i);
    shopout[b].push_back(i);

    imp.push_back(a), imp.push_back(b);
  }

  for(int i=0; i<q; ++i) {
    int x, y;
    cin>>x>>y;

    pos[i] = x;
    query[y].push_back(i);
    imp.push_back(y);
  }


  sort(imp.begin(), imp.end());
  imp.resize(unique(imp.begin(), imp.end())-imp.begin());

  for(int mom : imp) {
    //cerr<<mom<<endl;
    if(shopin.count(mom)) {
      for(int j : shopin[mom]) {
        live[t[j]].insert(x[j]);
      }
    }
    if(query.count(mom)) {
      for(int j : query[mom]) {
        for(int i=1; i<=k; ++i) {
          if(live[i].empty()) {
            ans[j] = -1;
            break;
          }
          int d1 = 1e9, d2 = 1e9;
          auto it = live[i].lower_bound(pos[j]);
          if(it!=live[i].end()) d1 = *it - pos[j];

          if(it!=live[i].begin()) {
            it = prev(it);
            d2 = pos[j] - *it;
          }

          ans[j] = max(ans[j], min(d1, d2));
        }

      }
    }
    if(shopout.count(mom)) {
      for(int j : shopout[mom]) {
        live[t[j]].erase(live[t[j]].find(x[j]));
      }
    }
  }

  for(int i=0; i<q; ++i) {
    cout<<ans[i]<<'\n';
  }
  // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3156 KB Output is correct
2 Correct 2 ms 3156 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3148 KB Output is correct
5 Correct 2 ms 3156 KB Output is correct
6 Correct 3 ms 3248 KB Output is correct
7 Correct 2 ms 3284 KB Output is correct
8 Correct 3 ms 3284 KB Output is correct
9 Correct 3 ms 3284 KB Output is correct
10 Correct 3 ms 3284 KB Output is correct
11 Correct 2 ms 3284 KB Output is correct
12 Correct 3 ms 3296 KB Output is correct
13 Correct 3 ms 3284 KB Output is correct
14 Correct 3 ms 3284 KB Output is correct
15 Correct 3 ms 3292 KB Output is correct
16 Correct 3 ms 3284 KB Output is correct
17 Correct 3 ms 3284 KB Output is correct
18 Correct 3 ms 3244 KB Output is correct
19 Correct 3 ms 3284 KB Output is correct
20 Correct 3 ms 3284 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 3 ms 3288 KB Output is correct
23 Correct 3 ms 3292 KB Output is correct
24 Correct 4 ms 3284 KB Output is correct
25 Correct 3 ms 3284 KB Output is correct
26 Correct 3 ms 3252 KB Output is correct
27 Correct 2 ms 3156 KB Output is correct
28 Correct 2 ms 3284 KB Output is correct
29 Correct 2 ms 3284 KB Output is correct
30 Correct 2 ms 3292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3156 KB Output is correct
2 Correct 2 ms 3156 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3148 KB Output is correct
5 Correct 2 ms 3156 KB Output is correct
6 Correct 3 ms 3248 KB Output is correct
7 Correct 2 ms 3284 KB Output is correct
8 Correct 3 ms 3284 KB Output is correct
9 Correct 3 ms 3284 KB Output is correct
10 Correct 3 ms 3284 KB Output is correct
11 Correct 2 ms 3284 KB Output is correct
12 Correct 3 ms 3296 KB Output is correct
13 Correct 3 ms 3284 KB Output is correct
14 Correct 3 ms 3284 KB Output is correct
15 Correct 3 ms 3292 KB Output is correct
16 Correct 3 ms 3284 KB Output is correct
17 Correct 3 ms 3284 KB Output is correct
18 Correct 3 ms 3244 KB Output is correct
19 Correct 3 ms 3284 KB Output is correct
20 Correct 3 ms 3284 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 3 ms 3288 KB Output is correct
23 Correct 3 ms 3292 KB Output is correct
24 Correct 4 ms 3284 KB Output is correct
25 Correct 3 ms 3284 KB Output is correct
26 Correct 3 ms 3252 KB Output is correct
27 Correct 2 ms 3156 KB Output is correct
28 Correct 2 ms 3284 KB Output is correct
29 Correct 2 ms 3284 KB Output is correct
30 Correct 2 ms 3292 KB Output is correct
31 Correct 1955 ms 30744 KB Output is correct
32 Correct 77 ms 7740 KB Output is correct
33 Correct 310 ms 28700 KB Output is correct
34 Correct 1527 ms 28988 KB Output is correct
35 Correct 949 ms 30624 KB Output is correct
36 Correct 338 ms 30564 KB Output is correct
37 Correct 275 ms 27948 KB Output is correct
38 Correct 201 ms 27848 KB Output is correct
39 Correct 168 ms 27636 KB Output is correct
40 Correct 164 ms 27736 KB Output is correct
41 Correct 356 ms 27928 KB Output is correct
42 Correct 305 ms 27860 KB Output is correct
43 Correct 185 ms 11120 KB Output is correct
44 Correct 340 ms 28040 KB Output is correct
45 Correct 208 ms 27908 KB Output is correct
46 Correct 154 ms 27864 KB Output is correct
47 Correct 135 ms 26864 KB Output is correct
48 Correct 131 ms 26740 KB Output is correct
49 Correct 144 ms 27256 KB Output is correct
50 Correct 252 ms 27572 KB Output is correct
51 Correct 141 ms 27060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 11660 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 124 ms 37204 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3156 KB Output is correct
2 Correct 2 ms 3156 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3148 KB Output is correct
5 Correct 2 ms 3156 KB Output is correct
6 Correct 3 ms 3248 KB Output is correct
7 Correct 2 ms 3284 KB Output is correct
8 Correct 3 ms 3284 KB Output is correct
9 Correct 3 ms 3284 KB Output is correct
10 Correct 3 ms 3284 KB Output is correct
11 Correct 2 ms 3284 KB Output is correct
12 Correct 3 ms 3296 KB Output is correct
13 Correct 3 ms 3284 KB Output is correct
14 Correct 3 ms 3284 KB Output is correct
15 Correct 3 ms 3292 KB Output is correct
16 Correct 3 ms 3284 KB Output is correct
17 Correct 3 ms 3284 KB Output is correct
18 Correct 3 ms 3244 KB Output is correct
19 Correct 3 ms 3284 KB Output is correct
20 Correct 3 ms 3284 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 3 ms 3288 KB Output is correct
23 Correct 3 ms 3292 KB Output is correct
24 Correct 4 ms 3284 KB Output is correct
25 Correct 3 ms 3284 KB Output is correct
26 Correct 3 ms 3252 KB Output is correct
27 Correct 2 ms 3156 KB Output is correct
28 Correct 2 ms 3284 KB Output is correct
29 Correct 2 ms 3284 KB Output is correct
30 Correct 2 ms 3292 KB Output is correct
31 Correct 1955 ms 30744 KB Output is correct
32 Correct 77 ms 7740 KB Output is correct
33 Correct 310 ms 28700 KB Output is correct
34 Correct 1527 ms 28988 KB Output is correct
35 Correct 949 ms 30624 KB Output is correct
36 Correct 338 ms 30564 KB Output is correct
37 Correct 275 ms 27948 KB Output is correct
38 Correct 201 ms 27848 KB Output is correct
39 Correct 168 ms 27636 KB Output is correct
40 Correct 164 ms 27736 KB Output is correct
41 Correct 356 ms 27928 KB Output is correct
42 Correct 305 ms 27860 KB Output is correct
43 Correct 185 ms 11120 KB Output is correct
44 Correct 340 ms 28040 KB Output is correct
45 Correct 208 ms 27908 KB Output is correct
46 Correct 154 ms 27864 KB Output is correct
47 Correct 135 ms 26864 KB Output is correct
48 Correct 131 ms 26740 KB Output is correct
49 Correct 144 ms 27256 KB Output is correct
50 Correct 252 ms 27572 KB Output is correct
51 Correct 141 ms 27060 KB Output is correct
52 Correct 222 ms 30524 KB Output is correct
53 Correct 215 ms 28812 KB Output is correct
54 Correct 250 ms 30412 KB Output is correct
55 Execution timed out 5063 ms 28412 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3156 KB Output is correct
2 Correct 2 ms 3156 KB Output is correct
3 Correct 2 ms 3152 KB Output is correct
4 Correct 2 ms 3148 KB Output is correct
5 Correct 2 ms 3156 KB Output is correct
6 Correct 3 ms 3248 KB Output is correct
7 Correct 2 ms 3284 KB Output is correct
8 Correct 3 ms 3284 KB Output is correct
9 Correct 3 ms 3284 KB Output is correct
10 Correct 3 ms 3284 KB Output is correct
11 Correct 2 ms 3284 KB Output is correct
12 Correct 3 ms 3296 KB Output is correct
13 Correct 3 ms 3284 KB Output is correct
14 Correct 3 ms 3284 KB Output is correct
15 Correct 3 ms 3292 KB Output is correct
16 Correct 3 ms 3284 KB Output is correct
17 Correct 3 ms 3284 KB Output is correct
18 Correct 3 ms 3244 KB Output is correct
19 Correct 3 ms 3284 KB Output is correct
20 Correct 3 ms 3284 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 3 ms 3288 KB Output is correct
23 Correct 3 ms 3292 KB Output is correct
24 Correct 4 ms 3284 KB Output is correct
25 Correct 3 ms 3284 KB Output is correct
26 Correct 3 ms 3252 KB Output is correct
27 Correct 2 ms 3156 KB Output is correct
28 Correct 2 ms 3284 KB Output is correct
29 Correct 2 ms 3284 KB Output is correct
30 Correct 2 ms 3292 KB Output is correct
31 Correct 1955 ms 30744 KB Output is correct
32 Correct 77 ms 7740 KB Output is correct
33 Correct 310 ms 28700 KB Output is correct
34 Correct 1527 ms 28988 KB Output is correct
35 Correct 949 ms 30624 KB Output is correct
36 Correct 338 ms 30564 KB Output is correct
37 Correct 275 ms 27948 KB Output is correct
38 Correct 201 ms 27848 KB Output is correct
39 Correct 168 ms 27636 KB Output is correct
40 Correct 164 ms 27736 KB Output is correct
41 Correct 356 ms 27928 KB Output is correct
42 Correct 305 ms 27860 KB Output is correct
43 Correct 185 ms 11120 KB Output is correct
44 Correct 340 ms 28040 KB Output is correct
45 Correct 208 ms 27908 KB Output is correct
46 Correct 154 ms 27864 KB Output is correct
47 Correct 135 ms 26864 KB Output is correct
48 Correct 131 ms 26740 KB Output is correct
49 Correct 144 ms 27256 KB Output is correct
50 Correct 252 ms 27572 KB Output is correct
51 Correct 141 ms 27060 KB Output is correct
52 Runtime error 55 ms 11660 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -