Submission #1187536

#TimeUsernameProblemLanguageResultExecution timeMemory
1187536mattsohNew Home (APIO18_new_home)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll maxn = 3e5 + 10;
const ll maxy = 1e8 + 10;
array<ll,4> stores[maxn];
vector<array<ll,4>> events[maxn];
pair<ll,ll> queries[maxn];
set<ll> evy;
ll res[maxn];
int stx[maxn][4 * maxn];
map<ll, ll> loc_id;
void update(ll type, ll id, ll left, ll right,ll x,ll val) {
    if (x>right || x <left) return;
    if (left == right){
        stx[type][id] += val;
        return;
    }
    ll mid = (left+right)/2;
    if (x <= mid){
        update(type, id*2, left, mid, x, val);
    }
    else{
        update(type, id*2+1, mid+1, right, x, val);
    }
    stx[type][id] = stx[type][2*id] + stx[type][2*id+1];
}

ll get(ll type, ll id, ll left, ll right, ll l, ll r) {
    if (stx[type][id] == 0 || l>right || r<left)
        return -1;
    if (left==right) return left;
    ll mid = (left+right)/2;
    ll res = get(type, 2*id+1, mid+1, right, l,r);
    if (res != -1) return res;
    return get(type, 2*id, left, mid, l,r);
}

int main() {
    ll n,k,q; cin>>n>>k>>q;
    vector<ll> locs;
    for (ll i = 0;i<n;i++) {
        ll x,t,s,e; cin>>x>>t>>s>>e;
        stores[i] = {x,t-1,s,e};
        locs.push_back(x);
    }
    for (ll i = 0; i < q; i++) {
        ll l, y;
        cin >> l >> y;
        queries[i] = {l, y};
        locs.push_back(l);
    }
    
    sort(locs.begin(),locs.end());
    ll sz = locs.size();
    for (ll i = 0;i<sz;i++) {
        loc_id[locs[i]] = i;
    }
    for (ll i = 0; i < n; i++) {
        auto [x, t, s, e] = stores[i];
        ll xi = loc_id[x];
        events[s].push_back({0, t, xi, -1}); 
        events[e + 1].push_back({1, t, xi, -1});
        evy.insert(s);
        evy.insert(e+1);
    }
    for (ll i = 0; i < q; i++) {
        auto [l, y] = queries[i];
        ll li = loc_id[l];
        events[y].push_back({2, -1, li, i});
        evy.insert(y);
    }
    for (ll i: evy) {
        auto evs = events[i];
        for (auto [type, t, xi, qi] : evs) {
            if (type == 0) {
                update(t, 1, 0, sz,xi,1);
            } else if (type == 1) {
                update(t, 1, 0, sz,xi,-1);
            } else {
                ll maxx = -1;
                for (ll j = 0; j < k; ++j) {
                    ll left = get(j,1,0,sz,0,xi);
                    ll right = get(j,1,0,sz,xi+1,sz);
                    if (left == -1 && right == -1) {
                        maxx = -1;
                        break;
                    }
                    ll dist = maxy;
                    if (left != -1)
                        dist = min(dist, abs(locs[xi] - locs[left]));
                    if (right != -1)
                        dist = min(dist, abs(locs[xi] - locs[right]));
                    maxx = max(maxx, dist);
                }
                res[qi] = maxx;
            }
        }
    }
    for (ll i = 0;i<q;i++){
        cout<<res[i]<<endl;
    }
}

Compilation message (stderr)

/tmp/cc5XUaIE.o: in function `__tcf_0':
new_home.cpp:(.text+0x1c9): relocation truncated to fit: R_X86_64_PC32 against symbol `events' defined in .bss section in /tmp/cc5XUaIE.o
/tmp/cc5XUaIE.o: in function `main':
new_home.cpp:(.text.startup+0xd): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
new_home.cpp:(.text.startup+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `stores' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x173): relocation truncated to fit: R_X86_64_PC32 against symbol `queries' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x30a): relocation truncated to fit: R_X86_64_PC32 against symbol `stores' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x318): relocation truncated to fit: R_X86_64_PC32 against symbol `evy' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x3b7): relocation truncated to fit: R_X86_64_PC32 against symbol `events' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x424): relocation truncated to fit: R_X86_64_PC32 against symbol `events' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x4cf): relocation truncated to fit: R_X86_64_PC32 against symbol `queries' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x4db): relocation truncated to fit: R_X86_64_PC32 against symbol `events' defined in .bss section in /tmp/cc5XUaIE.o
new_home.cpp:(.text.startup+0x5d9): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1c): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1c6): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x260): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2e2): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x353): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x541): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5e5): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x670): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x6e9): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
collect2: error: ld returned 1 exit status