#include <bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define MP make_pair
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
const int N = 1e5 + 5;
const int INF = 1e9 + 500;
const int K = 405;
int n, k, q;
vector<array<int, 4> > ev;
vector<array<int, 3> > qu;
vector<multiset<int> > st(K);
void solve() {
cin >> n >> k >> q;
REP(i, n) {
int x, t, a, b;
cin >> x >> t >> a >> b;
ev.pb({a, x, t, 1});
ev.pb({b + 1, x, t, 0});
}
qu.resize(q);
REP(i, q) {
cin >> qu[i][1] >> qu[i][0];
qu[i][2] = i;
}
sort(all(qu));
sort(all(ev));
int ind = 0;
vector<int> res(q, 0);
for(auto c : qu) {
while(ind < ev.size() && ev[ind][0] <= c[0]) {
if(ev[ind][3]) {
st[ev[ind][2]].insert(ev[ind][1]);
}
else {
st[ev[ind][2]].erase(st[ev[ind][2]].lower_bound(ev[ind][1]));
}
ind++;
}
int mx = 0;
for(int i = 1; i <= k; i++) {
if(st[i].empty()) {
mx = -1;
break;
}
auto itr = st[i].lower_bound(c[1]);
int mn = INF;
if(itr != st[i].end()) mn = min(mn, (*itr) - c[1]);
if(itr != st[i].begin()) {
itr--;
mn = min(mn, c[1] - (*itr));
}
mx = max(mx, mn);
}
res[c[2]] = mx;
}
REP(i, q) {
cout << res[i] << "\n";
}
}
signed main() {
fastio();
solve();
}
Compilation message
new_home.cpp: In function 'void solve()':
new_home.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | while(ind < ev.size() && ev[ind][0] <= c[0]) {
| ~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
516 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
516 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1474 ms |
9500 KB |
Output is correct |
32 |
Correct |
64 ms |
5484 KB |
Output is correct |
33 |
Correct |
120 ms |
7364 KB |
Output is correct |
34 |
Correct |
1143 ms |
7532 KB |
Output is correct |
35 |
Correct |
700 ms |
9488 KB |
Output is correct |
36 |
Correct |
142 ms |
9152 KB |
Output is correct |
37 |
Correct |
109 ms |
6616 KB |
Output is correct |
38 |
Correct |
66 ms |
6596 KB |
Output is correct |
39 |
Correct |
70 ms |
6412 KB |
Output is correct |
40 |
Correct |
70 ms |
6272 KB |
Output is correct |
41 |
Correct |
185 ms |
6756 KB |
Output is correct |
42 |
Correct |
145 ms |
6524 KB |
Output is correct |
43 |
Correct |
317 ms |
8948 KB |
Output is correct |
44 |
Correct |
158 ms |
6756 KB |
Output is correct |
45 |
Correct |
88 ms |
6716 KB |
Output is correct |
46 |
Correct |
51 ms |
6592 KB |
Output is correct |
47 |
Correct |
46 ms |
6156 KB |
Output is correct |
48 |
Correct |
44 ms |
6200 KB |
Output is correct |
49 |
Correct |
55 ms |
6340 KB |
Output is correct |
50 |
Correct |
129 ms |
6456 KB |
Output is correct |
51 |
Correct |
52 ms |
6272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
235 ms |
44968 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
237 ms |
44248 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
516 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1474 ms |
9500 KB |
Output is correct |
32 |
Correct |
64 ms |
5484 KB |
Output is correct |
33 |
Correct |
120 ms |
7364 KB |
Output is correct |
34 |
Correct |
1143 ms |
7532 KB |
Output is correct |
35 |
Correct |
700 ms |
9488 KB |
Output is correct |
36 |
Correct |
142 ms |
9152 KB |
Output is correct |
37 |
Correct |
109 ms |
6616 KB |
Output is correct |
38 |
Correct |
66 ms |
6596 KB |
Output is correct |
39 |
Correct |
70 ms |
6412 KB |
Output is correct |
40 |
Correct |
70 ms |
6272 KB |
Output is correct |
41 |
Correct |
185 ms |
6756 KB |
Output is correct |
42 |
Correct |
145 ms |
6524 KB |
Output is correct |
43 |
Correct |
317 ms |
8948 KB |
Output is correct |
44 |
Correct |
158 ms |
6756 KB |
Output is correct |
45 |
Correct |
88 ms |
6716 KB |
Output is correct |
46 |
Correct |
51 ms |
6592 KB |
Output is correct |
47 |
Correct |
46 ms |
6156 KB |
Output is correct |
48 |
Correct |
44 ms |
6200 KB |
Output is correct |
49 |
Correct |
55 ms |
6340 KB |
Output is correct |
50 |
Correct |
129 ms |
6456 KB |
Output is correct |
51 |
Correct |
52 ms |
6272 KB |
Output is correct |
52 |
Runtime error |
44 ms |
9412 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
516 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1474 ms |
9500 KB |
Output is correct |
32 |
Correct |
64 ms |
5484 KB |
Output is correct |
33 |
Correct |
120 ms |
7364 KB |
Output is correct |
34 |
Correct |
1143 ms |
7532 KB |
Output is correct |
35 |
Correct |
700 ms |
9488 KB |
Output is correct |
36 |
Correct |
142 ms |
9152 KB |
Output is correct |
37 |
Correct |
109 ms |
6616 KB |
Output is correct |
38 |
Correct |
66 ms |
6596 KB |
Output is correct |
39 |
Correct |
70 ms |
6412 KB |
Output is correct |
40 |
Correct |
70 ms |
6272 KB |
Output is correct |
41 |
Correct |
185 ms |
6756 KB |
Output is correct |
42 |
Correct |
145 ms |
6524 KB |
Output is correct |
43 |
Correct |
317 ms |
8948 KB |
Output is correct |
44 |
Correct |
158 ms |
6756 KB |
Output is correct |
45 |
Correct |
88 ms |
6716 KB |
Output is correct |
46 |
Correct |
51 ms |
6592 KB |
Output is correct |
47 |
Correct |
46 ms |
6156 KB |
Output is correct |
48 |
Correct |
44 ms |
6200 KB |
Output is correct |
49 |
Correct |
55 ms |
6340 KB |
Output is correct |
50 |
Correct |
129 ms |
6456 KB |
Output is correct |
51 |
Correct |
52 ms |
6272 KB |
Output is correct |
52 |
Runtime error |
235 ms |
44968 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |