답안 #742340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742340 2023-05-16T06:33:28 Z victor_gao 새 집 (APIO18_new_home) C++17
12 / 100
1897 ms 49348 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 60015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,q,k,x[N],t[N],a[N],b[N],l[N],y[N],ans[N];
multiset<int>st[505];
vector<pii>in[3*N],out[3*N],qry[3*N];
struct lisan{
    vector<int>vt;
    void in(int x){ vt.push_back(x); }
    void build(){
        sort(vt.begin(),vt.end());
        vt.resize(unique(vt.begin(),vt.end())-vt.begin());
    }
    int idx(int x){ return upper_bound(vt.begin(),vt.end(),x)-vt.begin(); }
}uni;
signed main(){
    fast
    cin>>n>>k>>q;
    for (int i=1;i<=n;i++){
        cin>>x[i]>>t[i]>>a[i]>>b[i];
        uni.in(a[i]); uni.in(b[i]+1);
    }
    for (int i=1;i<=q;i++){
        cin>>l[i]>>y[i];
        uni.in(y[i]);
    }
    uni.build();
    for (int i=1;i<=n;i++){
        in[uni.idx(a[i])].push_back({x[i],t[i]});
        out[uni.idx(b[i]+1)].push_back({x[i],t[i]});
    }
    for (int i=1;i<=q;i++){
        qry[uni.idx(y[i])].push_back({l[i],i});
    }
    for (int i=0;i<3*N;i++){
        for (auto j:in[i]){
            st[j.y].insert(j.x);
        }
        for (auto j:out[i]){
            st[j.y].erase(st[j.y].find(j.x));
        }
        for (auto [p,id]:qry[i]){
            int tans=-1;
            for (int j=1;j<=k;j++){
                if (st[j].empty()){
                    tans=-1;
                    break;
                }
                auto it=st[j].lower_bound(p);
                if (it==st[j].begin()) tans=max(tans,(*it)-p);
                else if (it==st[j].end()){
                    it=prev(it);
                    tans=max(tans,p-(*it));
                }
                else {
                    auto it1=prev(it);
                    tans=max(tans,min((*it)-p,p-(*it1)));
                }
            }
            ans[id]=tans;
        }
    }
    for (int i=1;i<=q;i++)
        cout<<ans[i]<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 8 ms 12948 KB Output is correct
4 Correct 8 ms 12956 KB Output is correct
5 Correct 9 ms 13140 KB Output is correct
6 Correct 8 ms 13112 KB Output is correct
7 Correct 8 ms 13104 KB Output is correct
8 Correct 8 ms 13060 KB Output is correct
9 Correct 8 ms 13100 KB Output is correct
10 Correct 9 ms 13140 KB Output is correct
11 Correct 8 ms 13064 KB Output is correct
12 Correct 8 ms 13060 KB Output is correct
13 Correct 9 ms 13064 KB Output is correct
14 Correct 8 ms 13140 KB Output is correct
15 Correct 9 ms 13152 KB Output is correct
16 Correct 9 ms 13052 KB Output is correct
17 Correct 9 ms 13140 KB Output is correct
18 Correct 10 ms 13140 KB Output is correct
19 Correct 9 ms 13060 KB Output is correct
20 Correct 9 ms 13140 KB Output is correct
21 Correct 8 ms 13140 KB Output is correct
22 Correct 9 ms 13084 KB Output is correct
23 Correct 9 ms 13060 KB Output is correct
24 Correct 9 ms 13060 KB Output is correct
25 Correct 8 ms 13172 KB Output is correct
26 Correct 8 ms 13140 KB Output is correct
27 Correct 9 ms 13076 KB Output is correct
28 Correct 8 ms 13140 KB Output is correct
29 Correct 9 ms 13140 KB Output is correct
30 Correct 9 ms 13152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 8 ms 12948 KB Output is correct
4 Correct 8 ms 12956 KB Output is correct
5 Correct 9 ms 13140 KB Output is correct
6 Correct 8 ms 13112 KB Output is correct
7 Correct 8 ms 13104 KB Output is correct
8 Correct 8 ms 13060 KB Output is correct
9 Correct 8 ms 13100 KB Output is correct
10 Correct 9 ms 13140 KB Output is correct
11 Correct 8 ms 13064 KB Output is correct
12 Correct 8 ms 13060 KB Output is correct
13 Correct 9 ms 13064 KB Output is correct
14 Correct 8 ms 13140 KB Output is correct
15 Correct 9 ms 13152 KB Output is correct
16 Correct 9 ms 13052 KB Output is correct
17 Correct 9 ms 13140 KB Output is correct
18 Correct 10 ms 13140 KB Output is correct
19 Correct 9 ms 13060 KB Output is correct
20 Correct 9 ms 13140 KB Output is correct
21 Correct 8 ms 13140 KB Output is correct
22 Correct 9 ms 13084 KB Output is correct
23 Correct 9 ms 13060 KB Output is correct
24 Correct 9 ms 13060 KB Output is correct
25 Correct 8 ms 13172 KB Output is correct
26 Correct 8 ms 13140 KB Output is correct
27 Correct 9 ms 13076 KB Output is correct
28 Correct 8 ms 13140 KB Output is correct
29 Correct 9 ms 13140 KB Output is correct
30 Correct 9 ms 13152 KB Output is correct
31 Correct 1897 ms 29508 KB Output is correct
32 Correct 89 ms 23200 KB Output is correct
33 Correct 214 ms 27656 KB Output is correct
34 Correct 1505 ms 27740 KB Output is correct
35 Correct 924 ms 29516 KB Output is correct
36 Correct 230 ms 29356 KB Output is correct
37 Correct 196 ms 26840 KB Output is correct
38 Correct 129 ms 26768 KB Output is correct
39 Correct 118 ms 26476 KB Output is correct
40 Correct 122 ms 26536 KB Output is correct
41 Correct 285 ms 26816 KB Output is correct
42 Correct 279 ms 26728 KB Output is correct
43 Correct 241 ms 26196 KB Output is correct
44 Correct 239 ms 26820 KB Output is correct
45 Correct 187 ms 26684 KB Output is correct
46 Correct 111 ms 26636 KB Output is correct
47 Correct 92 ms 26096 KB Output is correct
48 Correct 89 ms 26100 KB Output is correct
49 Correct 119 ms 26292 KB Output is correct
50 Correct 230 ms 26548 KB Output is correct
51 Correct 95 ms 26228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 32180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 32140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 8 ms 12948 KB Output is correct
4 Correct 8 ms 12956 KB Output is correct
5 Correct 9 ms 13140 KB Output is correct
6 Correct 8 ms 13112 KB Output is correct
7 Correct 8 ms 13104 KB Output is correct
8 Correct 8 ms 13060 KB Output is correct
9 Correct 8 ms 13100 KB Output is correct
10 Correct 9 ms 13140 KB Output is correct
11 Correct 8 ms 13064 KB Output is correct
12 Correct 8 ms 13060 KB Output is correct
13 Correct 9 ms 13064 KB Output is correct
14 Correct 8 ms 13140 KB Output is correct
15 Correct 9 ms 13152 KB Output is correct
16 Correct 9 ms 13052 KB Output is correct
17 Correct 9 ms 13140 KB Output is correct
18 Correct 10 ms 13140 KB Output is correct
19 Correct 9 ms 13060 KB Output is correct
20 Correct 9 ms 13140 KB Output is correct
21 Correct 8 ms 13140 KB Output is correct
22 Correct 9 ms 13084 KB Output is correct
23 Correct 9 ms 13060 KB Output is correct
24 Correct 9 ms 13060 KB Output is correct
25 Correct 8 ms 13172 KB Output is correct
26 Correct 8 ms 13140 KB Output is correct
27 Correct 9 ms 13076 KB Output is correct
28 Correct 8 ms 13140 KB Output is correct
29 Correct 9 ms 13140 KB Output is correct
30 Correct 9 ms 13152 KB Output is correct
31 Correct 1897 ms 29508 KB Output is correct
32 Correct 89 ms 23200 KB Output is correct
33 Correct 214 ms 27656 KB Output is correct
34 Correct 1505 ms 27740 KB Output is correct
35 Correct 924 ms 29516 KB Output is correct
36 Correct 230 ms 29356 KB Output is correct
37 Correct 196 ms 26840 KB Output is correct
38 Correct 129 ms 26768 KB Output is correct
39 Correct 118 ms 26476 KB Output is correct
40 Correct 122 ms 26536 KB Output is correct
41 Correct 285 ms 26816 KB Output is correct
42 Correct 279 ms 26728 KB Output is correct
43 Correct 241 ms 26196 KB Output is correct
44 Correct 239 ms 26820 KB Output is correct
45 Correct 187 ms 26684 KB Output is correct
46 Correct 111 ms 26636 KB Output is correct
47 Correct 92 ms 26096 KB Output is correct
48 Correct 89 ms 26100 KB Output is correct
49 Correct 119 ms 26292 KB Output is correct
50 Correct 230 ms 26548 KB Output is correct
51 Correct 95 ms 26228 KB Output is correct
52 Runtime error 107 ms 49348 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 13012 KB Output is correct
2 Correct 8 ms 13012 KB Output is correct
3 Correct 8 ms 12948 KB Output is correct
4 Correct 8 ms 12956 KB Output is correct
5 Correct 9 ms 13140 KB Output is correct
6 Correct 8 ms 13112 KB Output is correct
7 Correct 8 ms 13104 KB Output is correct
8 Correct 8 ms 13060 KB Output is correct
9 Correct 8 ms 13100 KB Output is correct
10 Correct 9 ms 13140 KB Output is correct
11 Correct 8 ms 13064 KB Output is correct
12 Correct 8 ms 13060 KB Output is correct
13 Correct 9 ms 13064 KB Output is correct
14 Correct 8 ms 13140 KB Output is correct
15 Correct 9 ms 13152 KB Output is correct
16 Correct 9 ms 13052 KB Output is correct
17 Correct 9 ms 13140 KB Output is correct
18 Correct 10 ms 13140 KB Output is correct
19 Correct 9 ms 13060 KB Output is correct
20 Correct 9 ms 13140 KB Output is correct
21 Correct 8 ms 13140 KB Output is correct
22 Correct 9 ms 13084 KB Output is correct
23 Correct 9 ms 13060 KB Output is correct
24 Correct 9 ms 13060 KB Output is correct
25 Correct 8 ms 13172 KB Output is correct
26 Correct 8 ms 13140 KB Output is correct
27 Correct 9 ms 13076 KB Output is correct
28 Correct 8 ms 13140 KB Output is correct
29 Correct 9 ms 13140 KB Output is correct
30 Correct 9 ms 13152 KB Output is correct
31 Correct 1897 ms 29508 KB Output is correct
32 Correct 89 ms 23200 KB Output is correct
33 Correct 214 ms 27656 KB Output is correct
34 Correct 1505 ms 27740 KB Output is correct
35 Correct 924 ms 29516 KB Output is correct
36 Correct 230 ms 29356 KB Output is correct
37 Correct 196 ms 26840 KB Output is correct
38 Correct 129 ms 26768 KB Output is correct
39 Correct 118 ms 26476 KB Output is correct
40 Correct 122 ms 26536 KB Output is correct
41 Correct 285 ms 26816 KB Output is correct
42 Correct 279 ms 26728 KB Output is correct
43 Correct 241 ms 26196 KB Output is correct
44 Correct 239 ms 26820 KB Output is correct
45 Correct 187 ms 26684 KB Output is correct
46 Correct 111 ms 26636 KB Output is correct
47 Correct 92 ms 26096 KB Output is correct
48 Correct 89 ms 26100 KB Output is correct
49 Correct 119 ms 26292 KB Output is correct
50 Correct 230 ms 26548 KB Output is correct
51 Correct 95 ms 26228 KB Output is correct
52 Runtime error 39 ms 32180 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -