답안 #743539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743539 2023-05-17T13:29:12 Z alvingogo 새 집 (APIO18_new_home) C++14
12 / 100
5000 ms 60460 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;

typedef pair<int,int> pii;
signed main(){
    AquA;
    int n,k,q;
    cin >> n >> k >> q;
    vector<pair<pii,pii> > vp(n);
    vector<pair<int,pii> > g;
    for(int i=0;i<n;i++){
        cin >> vp[i].fs.fs >> vp[i].fs.sc >> vp[i].sc.fs >> vp[i].sc.sc;
        g.push_back({vp[i].sc.fs,vp[i].fs});
        g.push_back({vp[i].sc.sc,{vp[i].fs.fs,-vp[i].fs.sc}});
    }
    vector<multiset<int> > s(k);
    for(int i=0;i<k;i++){
        s[i].insert(-2e9);
        s[i].insert(2e9);
    }
    vector<int> ans(q+1);
    for(int i=1;i<=q;i++){
        int l,y;
        cin >> l >> y;
        g.push_back({y,{-i,l}});
    }
    sort(g.begin(),g.end());
    vector<pii> ins,que,de;
    int nw=-1;
    for(auto t:g){
        if(t.fs!=nw){
            for(auto h:ins){
                s[h.sc-1].insert(h.fs);
            }
            for(auto h:que){
                for(int i=0;i<k;i++){
                    auto y=s[i].lower_bound(h.sc);
                    auto z=prev(y);
                    ans[-h.fs]=max(ans[-h.fs],min((*y)-h.sc,h.sc-(*z)));
                }
            }
            for(auto h:de){
                s[(-h.sc)-1].erase(s[(-h.sc)-1].find(h.fs));
            }
            ins.clear();
            que.clear();
            de.clear();
        }
        if(t.sc.fs<0){
            que.push_back(t.sc);
        }
        else if(t.sc.sc<0){
            de.push_back(t.sc);
        }
        else{
            ins.push_back(t.sc);
        }
        nw=t.fs;
    }
    for(auto h:ins){
        s[h.sc-1].insert(h.fs);
    }
    for(auto h:que){
        for(int i=0;i<k;i++){
            auto y=s[i].lower_bound(h.sc);
            auto z=prev(y);
            ans[-h.fs]=max(ans[-h.fs],min((*y)-h.sc,h.sc-(*z)));
        }
    }
    for(auto h:de){
        s[(-h.sc)-1].erase(s[(-h.sc)-1].find(h.fs));
    }
    for(int i=1;i<=q;i++){
        if(ans[i]>1e9){
            cout << -1 << "\n";
        }
        else{
            cout << ans[i] << "\n";
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1943 ms 10672 KB Output is correct
32 Correct 90 ms 9692 KB Output is correct
33 Correct 161 ms 11176 KB Output is correct
34 Correct 1546 ms 11320 KB Output is correct
35 Correct 839 ms 13160 KB Output is correct
36 Correct 175 ms 12852 KB Output is correct
37 Correct 139 ms 10988 KB Output is correct
38 Correct 82 ms 10940 KB Output is correct
39 Correct 76 ms 10940 KB Output is correct
40 Correct 73 ms 10980 KB Output is correct
41 Correct 289 ms 11124 KB Output is correct
42 Correct 342 ms 11168 KB Output is correct
43 Correct 513 ms 16528 KB Output is correct
44 Correct 257 ms 11116 KB Output is correct
45 Correct 115 ms 10984 KB Output is correct
46 Correct 69 ms 10940 KB Output is correct
47 Correct 62 ms 10868 KB Output is correct
48 Correct 58 ms 10832 KB Output is correct
49 Correct 73 ms 11044 KB Output is correct
50 Correct 204 ms 10948 KB Output is correct
51 Correct 65 ms 10812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5060 ms 60460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5030 ms 52736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1943 ms 10672 KB Output is correct
32 Correct 90 ms 9692 KB Output is correct
33 Correct 161 ms 11176 KB Output is correct
34 Correct 1546 ms 11320 KB Output is correct
35 Correct 839 ms 13160 KB Output is correct
36 Correct 175 ms 12852 KB Output is correct
37 Correct 139 ms 10988 KB Output is correct
38 Correct 82 ms 10940 KB Output is correct
39 Correct 76 ms 10940 KB Output is correct
40 Correct 73 ms 10980 KB Output is correct
41 Correct 289 ms 11124 KB Output is correct
42 Correct 342 ms 11168 KB Output is correct
43 Correct 513 ms 16528 KB Output is correct
44 Correct 257 ms 11116 KB Output is correct
45 Correct 115 ms 10984 KB Output is correct
46 Correct 69 ms 10940 KB Output is correct
47 Correct 62 ms 10868 KB Output is correct
48 Correct 58 ms 10832 KB Output is correct
49 Correct 73 ms 11044 KB Output is correct
50 Correct 204 ms 10948 KB Output is correct
51 Correct 65 ms 10812 KB Output is correct
52 Execution timed out 5069 ms 19644 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 352 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1943 ms 10672 KB Output is correct
32 Correct 90 ms 9692 KB Output is correct
33 Correct 161 ms 11176 KB Output is correct
34 Correct 1546 ms 11320 KB Output is correct
35 Correct 839 ms 13160 KB Output is correct
36 Correct 175 ms 12852 KB Output is correct
37 Correct 139 ms 10988 KB Output is correct
38 Correct 82 ms 10940 KB Output is correct
39 Correct 76 ms 10940 KB Output is correct
40 Correct 73 ms 10980 KB Output is correct
41 Correct 289 ms 11124 KB Output is correct
42 Correct 342 ms 11168 KB Output is correct
43 Correct 513 ms 16528 KB Output is correct
44 Correct 257 ms 11116 KB Output is correct
45 Correct 115 ms 10984 KB Output is correct
46 Correct 69 ms 10940 KB Output is correct
47 Correct 62 ms 10868 KB Output is correct
48 Correct 58 ms 10832 KB Output is correct
49 Correct 73 ms 11044 KB Output is correct
50 Correct 204 ms 10948 KB Output is correct
51 Correct 65 ms 10812 KB Output is correct
52 Execution timed out 5060 ms 60460 KB Time limit exceeded
53 Halted 0 ms 0 KB -