답안 #552454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552454 2022-04-23T07:47:01 Z zaneyu 새 집 (APIO18_new_home) C++14
12 / 100
5000 ms 56224 KB
/*input
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
*/
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma target("avx3")
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
const int maxn=3e5+5;
#define pb push_back
#define lowb(x) x&(-x)
#define ll long long
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pii pair<int,int>
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define sz(x) (int)x.size()
int ans[maxn];
multiset<int> s[maxn];
const int INF=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,k,q;
    cin>>n>>k>>q;
    vector<pair<pii,pii>> v;
    vector<pair<pii,int>> qq;
    REP(i,n){
        int x,t,a,b;
        cin>>x>>t>>a>>b;
        v.pb({{a,1},{x,t}});
        v.pb({{b+1,-1},{x,t}});
    }
    REP(i,q){
        int p,y;
        cin>>p>>y;
        qq.pb({{y,p},i});
    }
    sort(ALL(v)),sort(ALL(qq));
    int p=0;
    for(auto x:qq){
        while(p<sz(v) and v[p].f.f<=x.f.f){
            if(v[p].f.s==1){
                s[v[p].s.s].insert(v[p].s.f);
            }
            else{
                s[v[p].s.s].erase(s[v[p].s.s].find(v[p].s.f));
            }
            ++p;
        }
        int mx=0;
        REP1(i,k){
            auto it=s[i].lower_bound(x.f.s);
            int cur=INF;
            if(it!=s[i].end()) MNTO(cur,(*it)-x.f.s);
            if(it!=s[i].begin()){
                --it;
                MNTO(cur,x.f.s-(*it));
            }
            MXTO(mx,cur);
        }
        if(mx==INF) ans[x.s]=-1;
        else ans[x.s]=mx;
    }
    REP(i,q) cout<<ans[i]<<'\n';
}

Compilation message

new_home.cpp:14: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
   14 | #pragma target("avx3")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14424 KB Output is correct
3 Correct 8 ms 14428 KB Output is correct
4 Correct 7 ms 14428 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14372 KB Output is correct
7 Correct 9 ms 14432 KB Output is correct
8 Correct 9 ms 14420 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 8 ms 14444 KB Output is correct
13 Correct 8 ms 14420 KB Output is correct
14 Correct 8 ms 14396 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 9 ms 14420 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14420 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14484 KB Output is correct
22 Correct 9 ms 14440 KB Output is correct
23 Correct 10 ms 14420 KB Output is correct
24 Correct 8 ms 14472 KB Output is correct
25 Correct 9 ms 14420 KB Output is correct
26 Correct 9 ms 14420 KB Output is correct
27 Correct 8 ms 14364 KB Output is correct
28 Correct 8 ms 14420 KB Output is correct
29 Correct 9 ms 14484 KB Output is correct
30 Correct 9 ms 14436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14424 KB Output is correct
3 Correct 8 ms 14428 KB Output is correct
4 Correct 7 ms 14428 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14372 KB Output is correct
7 Correct 9 ms 14432 KB Output is correct
8 Correct 9 ms 14420 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 8 ms 14444 KB Output is correct
13 Correct 8 ms 14420 KB Output is correct
14 Correct 8 ms 14396 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 9 ms 14420 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14420 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14484 KB Output is correct
22 Correct 9 ms 14440 KB Output is correct
23 Correct 10 ms 14420 KB Output is correct
24 Correct 8 ms 14472 KB Output is correct
25 Correct 9 ms 14420 KB Output is correct
26 Correct 9 ms 14420 KB Output is correct
27 Correct 8 ms 14364 KB Output is correct
28 Correct 8 ms 14420 KB Output is correct
29 Correct 9 ms 14484 KB Output is correct
30 Correct 9 ms 14436 KB Output is correct
31 Correct 1821 ms 23512 KB Output is correct
32 Correct 71 ms 19392 KB Output is correct
33 Correct 154 ms 21492 KB Output is correct
34 Correct 1402 ms 21688 KB Output is correct
35 Correct 832 ms 23360 KB Output is correct
36 Correct 175 ms 23264 KB Output is correct
37 Correct 144 ms 21272 KB Output is correct
38 Correct 94 ms 21104 KB Output is correct
39 Correct 80 ms 21200 KB Output is correct
40 Correct 80 ms 21184 KB Output is correct
41 Correct 247 ms 21452 KB Output is correct
42 Correct 307 ms 21252 KB Output is correct
43 Correct 433 ms 22988 KB Output is correct
44 Correct 199 ms 21556 KB Output is correct
45 Correct 102 ms 21340 KB Output is correct
46 Correct 70 ms 21328 KB Output is correct
47 Correct 65 ms 20880 KB Output is correct
48 Correct 58 ms 20928 KB Output is correct
49 Correct 71 ms 21060 KB Output is correct
50 Correct 176 ms 21216 KB Output is correct
51 Correct 69 ms 21052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5055 ms 56224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5093 ms 55728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14424 KB Output is correct
3 Correct 8 ms 14428 KB Output is correct
4 Correct 7 ms 14428 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14372 KB Output is correct
7 Correct 9 ms 14432 KB Output is correct
8 Correct 9 ms 14420 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 8 ms 14444 KB Output is correct
13 Correct 8 ms 14420 KB Output is correct
14 Correct 8 ms 14396 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 9 ms 14420 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14420 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14484 KB Output is correct
22 Correct 9 ms 14440 KB Output is correct
23 Correct 10 ms 14420 KB Output is correct
24 Correct 8 ms 14472 KB Output is correct
25 Correct 9 ms 14420 KB Output is correct
26 Correct 9 ms 14420 KB Output is correct
27 Correct 8 ms 14364 KB Output is correct
28 Correct 8 ms 14420 KB Output is correct
29 Correct 9 ms 14484 KB Output is correct
30 Correct 9 ms 14436 KB Output is correct
31 Correct 1821 ms 23512 KB Output is correct
32 Correct 71 ms 19392 KB Output is correct
33 Correct 154 ms 21492 KB Output is correct
34 Correct 1402 ms 21688 KB Output is correct
35 Correct 832 ms 23360 KB Output is correct
36 Correct 175 ms 23264 KB Output is correct
37 Correct 144 ms 21272 KB Output is correct
38 Correct 94 ms 21104 KB Output is correct
39 Correct 80 ms 21200 KB Output is correct
40 Correct 80 ms 21184 KB Output is correct
41 Correct 247 ms 21452 KB Output is correct
42 Correct 307 ms 21252 KB Output is correct
43 Correct 433 ms 22988 KB Output is correct
44 Correct 199 ms 21556 KB Output is correct
45 Correct 102 ms 21340 KB Output is correct
46 Correct 70 ms 21328 KB Output is correct
47 Correct 65 ms 20880 KB Output is correct
48 Correct 58 ms 20928 KB Output is correct
49 Correct 71 ms 21060 KB Output is correct
50 Correct 176 ms 21216 KB Output is correct
51 Correct 69 ms 21052 KB Output is correct
52 Execution timed out 5079 ms 21612 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14420 KB Output is correct
2 Correct 7 ms 14424 KB Output is correct
3 Correct 8 ms 14428 KB Output is correct
4 Correct 7 ms 14428 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 7 ms 14372 KB Output is correct
7 Correct 9 ms 14432 KB Output is correct
8 Correct 9 ms 14420 KB Output is correct
9 Correct 9 ms 14420 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 8 ms 14444 KB Output is correct
13 Correct 8 ms 14420 KB Output is correct
14 Correct 8 ms 14396 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 9 ms 14420 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14420 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14484 KB Output is correct
22 Correct 9 ms 14440 KB Output is correct
23 Correct 10 ms 14420 KB Output is correct
24 Correct 8 ms 14472 KB Output is correct
25 Correct 9 ms 14420 KB Output is correct
26 Correct 9 ms 14420 KB Output is correct
27 Correct 8 ms 14364 KB Output is correct
28 Correct 8 ms 14420 KB Output is correct
29 Correct 9 ms 14484 KB Output is correct
30 Correct 9 ms 14436 KB Output is correct
31 Correct 1821 ms 23512 KB Output is correct
32 Correct 71 ms 19392 KB Output is correct
33 Correct 154 ms 21492 KB Output is correct
34 Correct 1402 ms 21688 KB Output is correct
35 Correct 832 ms 23360 KB Output is correct
36 Correct 175 ms 23264 KB Output is correct
37 Correct 144 ms 21272 KB Output is correct
38 Correct 94 ms 21104 KB Output is correct
39 Correct 80 ms 21200 KB Output is correct
40 Correct 80 ms 21184 KB Output is correct
41 Correct 247 ms 21452 KB Output is correct
42 Correct 307 ms 21252 KB Output is correct
43 Correct 433 ms 22988 KB Output is correct
44 Correct 199 ms 21556 KB Output is correct
45 Correct 102 ms 21340 KB Output is correct
46 Correct 70 ms 21328 KB Output is correct
47 Correct 65 ms 20880 KB Output is correct
48 Correct 58 ms 20928 KB Output is correct
49 Correct 71 ms 21060 KB Output is correct
50 Correct 176 ms 21216 KB Output is correct
51 Correct 69 ms 21052 KB Output is correct
52 Execution timed out 5055 ms 56224 KB Time limit exceeded
53 Halted 0 ms 0 KB -