Submission #260862

# Submission time Handle Problem Language Result Execution time Memory
260862 2020-08-11T06:15:19 Z wiwiho New Home (APIO18_new_home) C++14
12 / 100
5000 ms 90448 KB
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>

using namespace std;

typedef long long ll;

const ll MAX = 2147483647;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k, q;
    cin >> n >> k >> q;

    map<int, vector<pair<int, pii>>> e;
    for(int i = 0; i < n; i++){
        int x, t, a, b;
        cin >> x >> t >> a >> b;
        e[a].eb(mp(1, mp(x, t)));
        e[b + 1].eb(mp(-1, mp(x, t)));
    }

    for(int i = 0; i < q; i++){
        int l, y;
        cin >> l >> y;
        e[y].eb(mp(0, mp(l, i)));
    }

    vector<int> ans(q);

    vector<multiset<int>> p(k + 1);

    for(auto& i : e){
        for(auto j : i.S){
            if(j.F == 1) p[j.S.S].insert(j.S.F);
            else if(j.F == -1) p[j.S.S].erase(p[j.S.S].find(j.S.F));
            else{

                for(int t = 1;  t <= k; t++){
                    int tmp = MAX;
                    auto it = p[t].lower_bound(j.S.F);
                    if(it != p[t].end()) tmp = min(tmp, *it - j.S.F);
                    if(it != p[t].begin()) tmp = min(tmp, j.S.F - *prev(it));
                    ans[j.S.S] = max(ans[j.S.S], tmp);
                }

            }
        }
    }

    for(int i = 0; i < q; i++){
        if(ans[i] == MAX) cout << "-1\n";
        else cout << ans[i] << "\n";
    }

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 2331 ms 24236 KB Output is correct
32 Correct 108 ms 5364 KB Output is correct
33 Correct 363 ms 24696 KB Output is correct
34 Correct 1844 ms 24876 KB Output is correct
35 Correct 1124 ms 26488 KB Output is correct
36 Correct 391 ms 26744 KB Output is correct
37 Correct 266 ms 23800 KB Output is correct
38 Correct 208 ms 23672 KB Output is correct
39 Correct 170 ms 23544 KB Output is correct
40 Correct 184 ms 23600 KB Output is correct
41 Correct 427 ms 23788 KB Output is correct
42 Correct 511 ms 23672 KB Output is correct
43 Correct 227 ms 8364 KB Output is correct
44 Correct 377 ms 23928 KB Output is correct
45 Correct 273 ms 23800 KB Output is correct
46 Correct 195 ms 23672 KB Output is correct
47 Correct 135 ms 22780 KB Output is correct
48 Correct 135 ms 22648 KB Output is correct
49 Correct 171 ms 23032 KB Output is correct
50 Correct 302 ms 23544 KB Output is correct
51 Correct 173 ms 23032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 72060 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5086 ms 90448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 2331 ms 24236 KB Output is correct
32 Correct 108 ms 5364 KB Output is correct
33 Correct 363 ms 24696 KB Output is correct
34 Correct 1844 ms 24876 KB Output is correct
35 Correct 1124 ms 26488 KB Output is correct
36 Correct 391 ms 26744 KB Output is correct
37 Correct 266 ms 23800 KB Output is correct
38 Correct 208 ms 23672 KB Output is correct
39 Correct 170 ms 23544 KB Output is correct
40 Correct 184 ms 23600 KB Output is correct
41 Correct 427 ms 23788 KB Output is correct
42 Correct 511 ms 23672 KB Output is correct
43 Correct 227 ms 8364 KB Output is correct
44 Correct 377 ms 23928 KB Output is correct
45 Correct 273 ms 23800 KB Output is correct
46 Correct 195 ms 23672 KB Output is correct
47 Correct 135 ms 22780 KB Output is correct
48 Correct 135 ms 22648 KB Output is correct
49 Correct 171 ms 23032 KB Output is correct
50 Correct 302 ms 23544 KB Output is correct
51 Correct 173 ms 23032 KB Output is correct
52 Execution timed out 5064 ms 27308 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 2331 ms 24236 KB Output is correct
32 Correct 108 ms 5364 KB Output is correct
33 Correct 363 ms 24696 KB Output is correct
34 Correct 1844 ms 24876 KB Output is correct
35 Correct 1124 ms 26488 KB Output is correct
36 Correct 391 ms 26744 KB Output is correct
37 Correct 266 ms 23800 KB Output is correct
38 Correct 208 ms 23672 KB Output is correct
39 Correct 170 ms 23544 KB Output is correct
40 Correct 184 ms 23600 KB Output is correct
41 Correct 427 ms 23788 KB Output is correct
42 Correct 511 ms 23672 KB Output is correct
43 Correct 227 ms 8364 KB Output is correct
44 Correct 377 ms 23928 KB Output is correct
45 Correct 273 ms 23800 KB Output is correct
46 Correct 195 ms 23672 KB Output is correct
47 Correct 135 ms 22780 KB Output is correct
48 Correct 135 ms 22648 KB Output is correct
49 Correct 171 ms 23032 KB Output is correct
50 Correct 302 ms 23544 KB Output is correct
51 Correct 173 ms 23032 KB Output is correct
52 Execution timed out 5057 ms 72060 KB Time limit exceeded
53 Halted 0 ms 0 KB -