Submission #743527

# Submission time Handle Problem Language Result Execution time Memory
743527 2023-05-17T13:20:06 Z alvingogo New Home (APIO18_new_home) C++14
0 / 100
4843 ms 112836 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;
        vp[i].fs.sc--;
        g.push_back({vp[i].sc.fs,vp[i].fs});
        g.push_back({vp[i].sc.sc+1,{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(n+1);
    for(int i=1;i<=q;i++){
        int l,y;
        cin >> l >> y;
        g.push_back({l,{-i,y}});
    }
    sort(g.begin(),g.end());
    for(auto h:g){
        if(h.sc.fs<0){
            for(int i=0;i<k;i++){
                auto y=s[i].lower_bound(h.sc.sc);
                auto z=prev(y);
                ans[h.fs]=max(ans[h.fs],min((*y)-h.sc.sc,h.sc.sc-(*z)));
            }
        }
        else if(h.sc.sc<0){
            s[-h.sc.sc].erase(s[-h.sc.sc].find(h.sc.fs));
        }
        else{
            s[h.sc.sc].insert(h.sc.fs);
        }
    }
    for(int i=1;i<=q;i++){
        if(ans[i]>1e9){
            cout << -1 << "\n";
        }
        else{
            cout << ans[i] << "\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4843 ms 112836 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1116 ms 97416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -