답안 #976779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976779 2024-05-07T06:11:19 Z lighton 새 집 (APIO18_new_home) C++17
12 / 100
1467 ms 52896 KB
#include<bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
#define all(v) v.begin(),v.end()
using namespace std;

int n,k,q;
struct event{
    int col,t,q,qnum,x; //q=-1 : add , q=0 : update , q=1 : del
    bool operator<(const event &r) const{
        if(t==r.t) return q<r.q;
        else return t<r.t;
    }
};
vector<event> events;
int ans[300001];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k>>q;
    forf(i,1,n){
        int x,t,a,b;
        cin>>x>>t>>a>>b;
        events.push_back({t,a,-1,0,x});
        events.push_back({t,b,1,0,x});
    }
    forf(i,1,q){
        int l,y; cin>>l>>y;
        events.push_back({0,y,0,i,l});
    }

    sort(all(events));
    multiset<int> set1[401];
    for(auto &[nowcol,nowt,nowq,nowqnum,nowx] : events){
        if(nowq == -1) set1[nowcol].insert(nowx);
        else if(nowq==0){
            int nowans = 0;
            forf(col,1,k) {

                int tmp = 1e9;
                auto it = set1[col].lower_bound(nowx);
                if (it != set1[col].end()) tmp = min(tmp, *it - nowx);
                if (it != set1[col].begin()) tmp = min(tmp, nowx - *prev(it));
                nowans = max(nowans, tmp);
            }
            if (nowans == 1e9) nowans = -1;
            ans[nowqnum] = nowans;
        }
        else set1[nowcol].erase(set1[nowcol].find(nowx));
    }
    forf(i,1,q) cout<<ans[i]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 484 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 484 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1467 ms 10288 KB Output is correct
32 Correct 70 ms 8396 KB Output is correct
33 Correct 117 ms 8812 KB Output is correct
34 Correct 1260 ms 8816 KB Output is correct
35 Correct 674 ms 10204 KB Output is correct
36 Correct 146 ms 10960 KB Output is correct
37 Correct 107 ms 9172 KB Output is correct
38 Correct 74 ms 8652 KB Output is correct
39 Correct 69 ms 9420 KB Output is correct
40 Correct 58 ms 9872 KB Output is correct
41 Correct 191 ms 9312 KB Output is correct
42 Correct 244 ms 8880 KB Output is correct
43 Correct 196 ms 10268 KB Output is correct
44 Correct 154 ms 9080 KB Output is correct
45 Correct 87 ms 9388 KB Output is correct
46 Correct 53 ms 9148 KB Output is correct
47 Correct 49 ms 8824 KB Output is correct
48 Correct 45 ms 8636 KB Output is correct
49 Correct 57 ms 8592 KB Output is correct
50 Correct 144 ms 8672 KB Output is correct
51 Correct 51 ms 8888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 186 ms 52420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 229 ms 52896 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 484 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1467 ms 10288 KB Output is correct
32 Correct 70 ms 8396 KB Output is correct
33 Correct 117 ms 8812 KB Output is correct
34 Correct 1260 ms 8816 KB Output is correct
35 Correct 674 ms 10204 KB Output is correct
36 Correct 146 ms 10960 KB Output is correct
37 Correct 107 ms 9172 KB Output is correct
38 Correct 74 ms 8652 KB Output is correct
39 Correct 69 ms 9420 KB Output is correct
40 Correct 58 ms 9872 KB Output is correct
41 Correct 191 ms 9312 KB Output is correct
42 Correct 244 ms 8880 KB Output is correct
43 Correct 196 ms 10268 KB Output is correct
44 Correct 154 ms 9080 KB Output is correct
45 Correct 87 ms 9388 KB Output is correct
46 Correct 53 ms 9148 KB Output is correct
47 Correct 49 ms 8824 KB Output is correct
48 Correct 45 ms 8636 KB Output is correct
49 Correct 57 ms 8592 KB Output is correct
50 Correct 144 ms 8672 KB Output is correct
51 Correct 51 ms 8888 KB Output is correct
52 Runtime error 53 ms 10892 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 484 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 564 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1467 ms 10288 KB Output is correct
32 Correct 70 ms 8396 KB Output is correct
33 Correct 117 ms 8812 KB Output is correct
34 Correct 1260 ms 8816 KB Output is correct
35 Correct 674 ms 10204 KB Output is correct
36 Correct 146 ms 10960 KB Output is correct
37 Correct 107 ms 9172 KB Output is correct
38 Correct 74 ms 8652 KB Output is correct
39 Correct 69 ms 9420 KB Output is correct
40 Correct 58 ms 9872 KB Output is correct
41 Correct 191 ms 9312 KB Output is correct
42 Correct 244 ms 8880 KB Output is correct
43 Correct 196 ms 10268 KB Output is correct
44 Correct 154 ms 9080 KB Output is correct
45 Correct 87 ms 9388 KB Output is correct
46 Correct 53 ms 9148 KB Output is correct
47 Correct 49 ms 8824 KB Output is correct
48 Correct 45 ms 8636 KB Output is correct
49 Correct 57 ms 8592 KB Output is correct
50 Correct 144 ms 8672 KB Output is correct
51 Correct 51 ms 8888 KB Output is correct
52 Runtime error 186 ms 52420 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -