#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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 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 |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
492 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 |
536 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 |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 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 |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
492 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 |
536 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 |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1552 ms |
8156 KB |
Output is correct |
32 |
Correct |
57 ms |
5300 KB |
Output is correct |
33 |
Correct |
123 ms |
6372 KB |
Output is correct |
34 |
Correct |
1145 ms |
6364 KB |
Output is correct |
35 |
Correct |
658 ms |
8152 KB |
Output is correct |
36 |
Correct |
142 ms |
8180 KB |
Output is correct |
37 |
Correct |
108 ms |
5568 KB |
Output is correct |
38 |
Correct |
68 ms |
5544 KB |
Output is correct |
39 |
Correct |
58 ms |
5308 KB |
Output is correct |
40 |
Correct |
58 ms |
5360 KB |
Output is correct |
41 |
Correct |
185 ms |
5612 KB |
Output is correct |
42 |
Correct |
147 ms |
5368 KB |
Output is correct |
43 |
Correct |
406 ms |
8148 KB |
Output is correct |
44 |
Correct |
163 ms |
5824 KB |
Output is correct |
45 |
Correct |
82 ms |
5588 KB |
Output is correct |
46 |
Correct |
51 ms |
5604 KB |
Output is correct |
47 |
Correct |
46 ms |
4804 KB |
Output is correct |
48 |
Correct |
42 ms |
4808 KB |
Output is correct |
49 |
Correct |
56 ms |
5056 KB |
Output is correct |
50 |
Correct |
130 ms |
5312 KB |
Output is correct |
51 |
Correct |
49 ms |
5060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
235 ms |
40028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
247 ms |
39640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 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 |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
492 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 |
536 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 |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1552 ms |
8156 KB |
Output is correct |
32 |
Correct |
57 ms |
5300 KB |
Output is correct |
33 |
Correct |
123 ms |
6372 KB |
Output is correct |
34 |
Correct |
1145 ms |
6364 KB |
Output is correct |
35 |
Correct |
658 ms |
8152 KB |
Output is correct |
36 |
Correct |
142 ms |
8180 KB |
Output is correct |
37 |
Correct |
108 ms |
5568 KB |
Output is correct |
38 |
Correct |
68 ms |
5544 KB |
Output is correct |
39 |
Correct |
58 ms |
5308 KB |
Output is correct |
40 |
Correct |
58 ms |
5360 KB |
Output is correct |
41 |
Correct |
185 ms |
5612 KB |
Output is correct |
42 |
Correct |
147 ms |
5368 KB |
Output is correct |
43 |
Correct |
406 ms |
8148 KB |
Output is correct |
44 |
Correct |
163 ms |
5824 KB |
Output is correct |
45 |
Correct |
82 ms |
5588 KB |
Output is correct |
46 |
Correct |
51 ms |
5604 KB |
Output is correct |
47 |
Correct |
46 ms |
4804 KB |
Output is correct |
48 |
Correct |
42 ms |
4808 KB |
Output is correct |
49 |
Correct |
56 ms |
5056 KB |
Output is correct |
50 |
Correct |
130 ms |
5312 KB |
Output is correct |
51 |
Correct |
49 ms |
5060 KB |
Output is correct |
52 |
Runtime error |
45 ms |
7932 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
1 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 |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
348 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 |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
492 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 |
536 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 |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1552 ms |
8156 KB |
Output is correct |
32 |
Correct |
57 ms |
5300 KB |
Output is correct |
33 |
Correct |
123 ms |
6372 KB |
Output is correct |
34 |
Correct |
1145 ms |
6364 KB |
Output is correct |
35 |
Correct |
658 ms |
8152 KB |
Output is correct |
36 |
Correct |
142 ms |
8180 KB |
Output is correct |
37 |
Correct |
108 ms |
5568 KB |
Output is correct |
38 |
Correct |
68 ms |
5544 KB |
Output is correct |
39 |
Correct |
58 ms |
5308 KB |
Output is correct |
40 |
Correct |
58 ms |
5360 KB |
Output is correct |
41 |
Correct |
185 ms |
5612 KB |
Output is correct |
42 |
Correct |
147 ms |
5368 KB |
Output is correct |
43 |
Correct |
406 ms |
8148 KB |
Output is correct |
44 |
Correct |
163 ms |
5824 KB |
Output is correct |
45 |
Correct |
82 ms |
5588 KB |
Output is correct |
46 |
Correct |
51 ms |
5604 KB |
Output is correct |
47 |
Correct |
46 ms |
4804 KB |
Output is correct |
48 |
Correct |
42 ms |
4808 KB |
Output is correct |
49 |
Correct |
56 ms |
5056 KB |
Output is correct |
50 |
Correct |
130 ms |
5312 KB |
Output is correct |
51 |
Correct |
49 ms |
5060 KB |
Output is correct |
52 |
Runtime error |
235 ms |
40028 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |