답안 #260851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260851 2020-08-11T05:53:12 Z wiwiho 새 집 (APIO18_new_home) C++14
5 / 100
5000 ms 1048580 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;
}
# 결과 실행 시간 메모리 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 3 ms 896 KB Output is correct
7 Correct 73 ms 18044 KB Output is correct
8 Correct 23 ms 6272 KB Output is correct
9 Correct 66 ms 18072 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 512 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 22 ms 6912 KB Output is correct
16 Correct 36 ms 9848 KB Output is correct
17 Correct 9 ms 3072 KB Output is correct
18 Correct 25 ms 7296 KB Output is correct
19 Correct 33 ms 10104 KB Output is correct
20 Correct 10 ms 3328 KB Output is correct
21 Correct 6 ms 2176 KB Output is correct
22 Correct 60 ms 18048 KB Output is correct
23 Correct 37 ms 9848 KB Output is correct
24 Correct 23 ms 6272 KB Output is correct
25 Correct 8 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
# 결과 실행 시간 메모리 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 3 ms 896 KB Output is correct
7 Correct 73 ms 18044 KB Output is correct
8 Correct 23 ms 6272 KB Output is correct
9 Correct 66 ms 18072 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 512 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 22 ms 6912 KB Output is correct
16 Correct 36 ms 9848 KB Output is correct
17 Correct 9 ms 3072 KB Output is correct
18 Correct 25 ms 7296 KB Output is correct
19 Correct 33 ms 10104 KB Output is correct
20 Correct 10 ms 3328 KB Output is correct
21 Correct 6 ms 2176 KB Output is correct
22 Correct 60 ms 18048 KB Output is correct
23 Correct 37 ms 9848 KB Output is correct
24 Correct 23 ms 6272 KB Output is correct
25 Correct 8 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 5059 ms 556224 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2178 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5080 ms 527284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 896 KB Output is correct
7 Correct 73 ms 18044 KB Output is correct
8 Correct 23 ms 6272 KB Output is correct
9 Correct 66 ms 18072 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 512 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 22 ms 6912 KB Output is correct
16 Correct 36 ms 9848 KB Output is correct
17 Correct 9 ms 3072 KB Output is correct
18 Correct 25 ms 7296 KB Output is correct
19 Correct 33 ms 10104 KB Output is correct
20 Correct 10 ms 3328 KB Output is correct
21 Correct 6 ms 2176 KB Output is correct
22 Correct 60 ms 18048 KB Output is correct
23 Correct 37 ms 9848 KB Output is correct
24 Correct 23 ms 6272 KB Output is correct
25 Correct 8 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 5059 ms 556224 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 896 KB Output is correct
7 Correct 73 ms 18044 KB Output is correct
8 Correct 23 ms 6272 KB Output is correct
9 Correct 66 ms 18072 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 512 KB Output is correct
13 Correct 2 ms 640 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 22 ms 6912 KB Output is correct
16 Correct 36 ms 9848 KB Output is correct
17 Correct 9 ms 3072 KB Output is correct
18 Correct 25 ms 7296 KB Output is correct
19 Correct 33 ms 10104 KB Output is correct
20 Correct 10 ms 3328 KB Output is correct
21 Correct 6 ms 2176 KB Output is correct
22 Correct 60 ms 18048 KB Output is correct
23 Correct 37 ms 9848 KB Output is correct
24 Correct 23 ms 6272 KB Output is correct
25 Correct 8 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 5059 ms 556224 KB Time limit exceeded
32 Halted 0 ms 0 KB -