Submission #260859

# Submission time Handle Problem Language Result Execution time Memory
260859 2020-08-11T06:07:58 Z wiwiho New Home (APIO18_new_home) C++14
5 / 100
5000 ms 1048576 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;
     
        vector<map<int, vector<pii>>> e(k + 1);
        for(int i = 0; i < n; i++){
            int x, t, a, b;
            cin >> x >> t >> a >> b;
            e[t][a].eb(mp(-1, x));
            e[t][b + 1].eb(mp(-2, x));
        }
     
        for(int i = 0; i < q; i++){
            int l, y;
            cin >> l >> y;
            for(int j = 1; j <= k; j++) e[j][y].eb(mp(i, l));
        }
     
        vector<int> ans(q);
     
        for(int t = 1; t <= k; t++){
     
            multiset<int> st;
            for(auto& j : e[t]){
                for(pii i : j.S){
                    if(i.F == -1) st.insert(i.S);
                    else if(i.F == -2) st.erase(st.find(i.S));
                    else{
                        int id = i.F, l = i.S;
                        auto it = st.lower_bound(l);
                        int dis = MAX;
                        if(it != st.end()) dis = min(dis, *it - l);
                        if(it != st.begin()) dis = min(dis, l - *prev(it));
                        //cerr << id << " " << t << " " << dis << "\n";
                        ans[id] = max(ans[id], dis);
                    }
                }
            }
     
        }
     
        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 1 ms 384 KB Output is correct
3 Correct 1 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 4 ms 896 KB Output is correct
7 Correct 60 ms 18048 KB Output is correct
8 Correct 21 ms 6272 KB Output is correct
9 Correct 58 ms 18040 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 4 ms 1280 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 20 ms 7040 KB Output is correct
16 Correct 27 ms 9856 KB Output is correct
17 Correct 8 ms 3072 KB Output is correct
18 Correct 20 ms 7296 KB Output is correct
19 Correct 28 ms 10112 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 5 ms 2176 KB Output is correct
22 Correct 53 ms 18040 KB Output is correct
23 Correct 30 ms 9856 KB Output is correct
24 Correct 18 ms 6272 KB Output is correct
25 Correct 7 ms 2432 KB Output is correct
26 Correct 2 ms 640 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 2 ms 896 KB Output is correct
29 Correct 2 ms 640 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 1 ms 384 KB Output is correct
3 Correct 1 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 4 ms 896 KB Output is correct
7 Correct 60 ms 18048 KB Output is correct
8 Correct 21 ms 6272 KB Output is correct
9 Correct 58 ms 18040 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 4 ms 1280 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 20 ms 7040 KB Output is correct
16 Correct 27 ms 9856 KB Output is correct
17 Correct 8 ms 3072 KB Output is correct
18 Correct 20 ms 7296 KB Output is correct
19 Correct 28 ms 10112 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 5 ms 2176 KB Output is correct
22 Correct 53 ms 18040 KB Output is correct
23 Correct 30 ms 9856 KB Output is correct
24 Correct 18 ms 6272 KB Output is correct
25 Correct 7 ms 2432 KB Output is correct
26 Correct 2 ms 640 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 2 ms 896 KB Output is correct
29 Correct 2 ms 640 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Execution timed out 5079 ms 522812 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2050 ms 1048576 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5116 ms 533340 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 1 ms 384 KB Output is correct
3 Correct 1 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 4 ms 896 KB Output is correct
7 Correct 60 ms 18048 KB Output is correct
8 Correct 21 ms 6272 KB Output is correct
9 Correct 58 ms 18040 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 4 ms 1280 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 20 ms 7040 KB Output is correct
16 Correct 27 ms 9856 KB Output is correct
17 Correct 8 ms 3072 KB Output is correct
18 Correct 20 ms 7296 KB Output is correct
19 Correct 28 ms 10112 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 5 ms 2176 KB Output is correct
22 Correct 53 ms 18040 KB Output is correct
23 Correct 30 ms 9856 KB Output is correct
24 Correct 18 ms 6272 KB Output is correct
25 Correct 7 ms 2432 KB Output is correct
26 Correct 2 ms 640 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 2 ms 896 KB Output is correct
29 Correct 2 ms 640 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Execution timed out 5079 ms 522812 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 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 4 ms 896 KB Output is correct
7 Correct 60 ms 18048 KB Output is correct
8 Correct 21 ms 6272 KB Output is correct
9 Correct 58 ms 18040 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 4 ms 1280 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 1 ms 512 KB Output is correct
15 Correct 20 ms 7040 KB Output is correct
16 Correct 27 ms 9856 KB Output is correct
17 Correct 8 ms 3072 KB Output is correct
18 Correct 20 ms 7296 KB Output is correct
19 Correct 28 ms 10112 KB Output is correct
20 Correct 9 ms 3328 KB Output is correct
21 Correct 5 ms 2176 KB Output is correct
22 Correct 53 ms 18040 KB Output is correct
23 Correct 30 ms 9856 KB Output is correct
24 Correct 18 ms 6272 KB Output is correct
25 Correct 7 ms 2432 KB Output is correct
26 Correct 2 ms 640 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 2 ms 896 KB Output is correct
29 Correct 2 ms 640 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Execution timed out 5079 ms 522812 KB Time limit exceeded
32 Halted 0 ms 0 KB -