Submission #983335

# Submission time Handle Problem Language Result Execution time Memory
983335 2024-05-15T10:24:16 Z vjudge1 New Home (APIO18_new_home) C++17
12 / 100
5000 ms 89292 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k, q, i, j, l, y, cur, x[300001], t[300001], a[300001], b[300001], ans[300001];
vector<pair<pair<int, int>, pair<int, int>>> v, g[300001];
multiset<int> ms[300001];

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	cin >> n >> k >> q;
	for (i = 1; i <= n; i++) {
		cin >> x[i] >> t[i] >> a[i] >> b[i];
		//g[t[i]].push_back({{a[i], b[i]}, x[i]});
		v.push_back({{a[i], -1}, {x[i], t[i]}});
		v.push_back({{b[i], q + 1}, {x[i], t[i]}});
	}
	for (i = 1; i <= k; i++) sort(g[i].begin(), g[i].end());
	for (i = 0; i < q; i++) {
		cin >> l >> y;
		v.push_back({{y, i}, {l, -1}});
	}
	sort(v.begin(), v.end());
	for (auto w : v) {
		if (w.first.second == -1) ms[w.second.second].insert(w.second.first);
		else if (w.first.second == q + 1) ms[w.second.second].erase(ms[w.second.second].find(w.second.first));
		else {
			y = w.first.first, l = w.second.first;
			j = w.first.second;
			ans[j] = 0;
			for (i = 1; i <= k; i++) {
				cur = 1e18;
				auto it = ms[i].lower_bound(l);
				if (it != ms[i].end()) cur = min(cur, abs(l - *it));
				if (it != ms[i].begin()) {
					it--;
					cur = min(cur, abs(l - *it));
				}
				//cout << w.first.first << " " << w.second.first << " " << i << " " << cur << "\n";
				if (cur >= 1e17) {
					ans[j] = -1;
					break;
				}
				ans[j] = max(ans[j], cur);
			}
		}
	}
	for (i = 0; i < q; i++) cout << ans[i] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 7 ms 31324 KB Output is correct
4 Correct 6 ms 31360 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 7 ms 31324 KB Output is correct
7 Correct 7 ms 31320 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 6 ms 31324 KB Output is correct
10 Correct 7 ms 31404 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31320 KB Output is correct
13 Correct 6 ms 31344 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31324 KB Output is correct
16 Correct 7 ms 31324 KB Output is correct
17 Correct 7 ms 31324 KB Output is correct
18 Correct 7 ms 31332 KB Output is correct
19 Correct 8 ms 31500 KB Output is correct
20 Correct 8 ms 31320 KB Output is correct
21 Correct 7 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31356 KB Output is correct
24 Correct 8 ms 31324 KB Output is correct
25 Correct 7 ms 31324 KB Output is correct
26 Correct 7 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 7 ms 31320 KB Output is correct
30 Correct 6 ms 31324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 7 ms 31324 KB Output is correct
4 Correct 6 ms 31360 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 7 ms 31324 KB Output is correct
7 Correct 7 ms 31320 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 6 ms 31324 KB Output is correct
10 Correct 7 ms 31404 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31320 KB Output is correct
13 Correct 6 ms 31344 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31324 KB Output is correct
16 Correct 7 ms 31324 KB Output is correct
17 Correct 7 ms 31324 KB Output is correct
18 Correct 7 ms 31332 KB Output is correct
19 Correct 8 ms 31500 KB Output is correct
20 Correct 8 ms 31320 KB Output is correct
21 Correct 7 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31356 KB Output is correct
24 Correct 8 ms 31324 KB Output is correct
25 Correct 7 ms 31324 KB Output is correct
26 Correct 7 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 7 ms 31320 KB Output is correct
30 Correct 6 ms 31324 KB Output is correct
31 Correct 1585 ms 44500 KB Output is correct
32 Correct 76 ms 42516 KB Output is correct
33 Correct 126 ms 42448 KB Output is correct
34 Correct 1282 ms 43728 KB Output is correct
35 Correct 746 ms 43716 KB Output is correct
36 Correct 152 ms 44272 KB Output is correct
37 Correct 121 ms 43204 KB Output is correct
38 Correct 84 ms 43912 KB Output is correct
39 Correct 67 ms 42448 KB Output is correct
40 Correct 75 ms 42484 KB Output is correct
41 Correct 206 ms 43696 KB Output is correct
42 Correct 157 ms 42312 KB Output is correct
43 Correct 406 ms 44444 KB Output is correct
44 Correct 184 ms 42408 KB Output is correct
45 Correct 92 ms 42180 KB Output is correct
46 Correct 68 ms 42176 KB Output is correct
47 Correct 54 ms 42084 KB Output is correct
48 Correct 51 ms 42956 KB Output is correct
49 Correct 69 ms 42076 KB Output is correct
50 Correct 150 ms 43604 KB Output is correct
51 Correct 57 ms 42704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5012 ms 89292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5013 ms 89180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 7 ms 31324 KB Output is correct
4 Correct 6 ms 31360 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 7 ms 31324 KB Output is correct
7 Correct 7 ms 31320 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 6 ms 31324 KB Output is correct
10 Correct 7 ms 31404 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31320 KB Output is correct
13 Correct 6 ms 31344 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31324 KB Output is correct
16 Correct 7 ms 31324 KB Output is correct
17 Correct 7 ms 31324 KB Output is correct
18 Correct 7 ms 31332 KB Output is correct
19 Correct 8 ms 31500 KB Output is correct
20 Correct 8 ms 31320 KB Output is correct
21 Correct 7 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31356 KB Output is correct
24 Correct 8 ms 31324 KB Output is correct
25 Correct 7 ms 31324 KB Output is correct
26 Correct 7 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 7 ms 31320 KB Output is correct
30 Correct 6 ms 31324 KB Output is correct
31 Correct 1585 ms 44500 KB Output is correct
32 Correct 76 ms 42516 KB Output is correct
33 Correct 126 ms 42448 KB Output is correct
34 Correct 1282 ms 43728 KB Output is correct
35 Correct 746 ms 43716 KB Output is correct
36 Correct 152 ms 44272 KB Output is correct
37 Correct 121 ms 43204 KB Output is correct
38 Correct 84 ms 43912 KB Output is correct
39 Correct 67 ms 42448 KB Output is correct
40 Correct 75 ms 42484 KB Output is correct
41 Correct 206 ms 43696 KB Output is correct
42 Correct 157 ms 42312 KB Output is correct
43 Correct 406 ms 44444 KB Output is correct
44 Correct 184 ms 42408 KB Output is correct
45 Correct 92 ms 42180 KB Output is correct
46 Correct 68 ms 42176 KB Output is correct
47 Correct 54 ms 42084 KB Output is correct
48 Correct 51 ms 42956 KB Output is correct
49 Correct 69 ms 42076 KB Output is correct
50 Correct 150 ms 43604 KB Output is correct
51 Correct 57 ms 42704 KB Output is correct
52 Correct 73 ms 43872 KB Output is correct
53 Correct 59 ms 42944 KB Output is correct
54 Correct 108 ms 43696 KB Output is correct
55 Execution timed out 5087 ms 43204 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 31324 KB Output is correct
2 Correct 6 ms 31324 KB Output is correct
3 Correct 7 ms 31324 KB Output is correct
4 Correct 6 ms 31360 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 7 ms 31324 KB Output is correct
7 Correct 7 ms 31320 KB Output is correct
8 Correct 8 ms 31324 KB Output is correct
9 Correct 6 ms 31324 KB Output is correct
10 Correct 7 ms 31404 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 6 ms 31320 KB Output is correct
13 Correct 6 ms 31344 KB Output is correct
14 Correct 6 ms 31324 KB Output is correct
15 Correct 7 ms 31324 KB Output is correct
16 Correct 7 ms 31324 KB Output is correct
17 Correct 7 ms 31324 KB Output is correct
18 Correct 7 ms 31332 KB Output is correct
19 Correct 8 ms 31500 KB Output is correct
20 Correct 8 ms 31320 KB Output is correct
21 Correct 7 ms 31324 KB Output is correct
22 Correct 7 ms 31324 KB Output is correct
23 Correct 7 ms 31356 KB Output is correct
24 Correct 8 ms 31324 KB Output is correct
25 Correct 7 ms 31324 KB Output is correct
26 Correct 7 ms 31324 KB Output is correct
27 Correct 7 ms 31320 KB Output is correct
28 Correct 6 ms 31324 KB Output is correct
29 Correct 7 ms 31320 KB Output is correct
30 Correct 6 ms 31324 KB Output is correct
31 Correct 1585 ms 44500 KB Output is correct
32 Correct 76 ms 42516 KB Output is correct
33 Correct 126 ms 42448 KB Output is correct
34 Correct 1282 ms 43728 KB Output is correct
35 Correct 746 ms 43716 KB Output is correct
36 Correct 152 ms 44272 KB Output is correct
37 Correct 121 ms 43204 KB Output is correct
38 Correct 84 ms 43912 KB Output is correct
39 Correct 67 ms 42448 KB Output is correct
40 Correct 75 ms 42484 KB Output is correct
41 Correct 206 ms 43696 KB Output is correct
42 Correct 157 ms 42312 KB Output is correct
43 Correct 406 ms 44444 KB Output is correct
44 Correct 184 ms 42408 KB Output is correct
45 Correct 92 ms 42180 KB Output is correct
46 Correct 68 ms 42176 KB Output is correct
47 Correct 54 ms 42084 KB Output is correct
48 Correct 51 ms 42956 KB Output is correct
49 Correct 69 ms 42076 KB Output is correct
50 Correct 150 ms 43604 KB Output is correct
51 Correct 57 ms 42704 KB Output is correct
52 Execution timed out 5012 ms 89292 KB Time limit exceeded
53 Halted 0 ms 0 KB -