제출 #1364485

#제출 시각아이디문제언어결과실행 시간메모리
1364485alexddBodyguard (JOI21_bodyguard)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 2805;
const int MAXQ = 3e6 + 5;
const int INF = 1e18;

void chmax(int&x, int val)
{
    x = max(x, val);
}


int n,q;

int t[MAXN], a[MAXN], b[MAXN], c[MAXN];
pair<int,int> from[MAXN], to[MAXN];

map<int,int> mp1, mp2;
unordered_map<int,int> nrm1, nrm2;
int cate1, cate2;
int inv1[2*MAXN], inv2[2*MAXN];

int dp[2*MAXN][2*MAXN];
int move1[2*MAXN][2*MAXN], move2[2*MAXN][2*MAXN];
vector<int> baga1[2*MAXN][2*MAXN], scoate1[2*MAXN][2*MAXN];
vector<int> baga2[2*MAXN][2*MAXN], scoate2[2*MAXN][2*MAXN];

void precalc()
{
    for(int i=1;i<=n;i++)
    {
        //optimize this--------------------------------------------------------------
        if(from[i].first == to[i].first)
        {
            assert(from[i].second < to[i].second);
            //for(int u=nrm2[from[i].second];u<nrm2[to[i].second];u++)
              //  chmax(move2[nrm1[from[i].first]][u], c[i]);
            baga2[nrm1[from[i].first]][nrm2[from[i].second]].push_back(c[i]);
            scoate2[nrm1[from[i].first]][nrm2[to[i].second]].push_back(c[i]);
        }
        else
        {
            assert(from[i].second == to[i].second);
            assert(from[i].first < to[i].first);
            //for(int u=nrm1[from[i].first];u<nrm1[to[i].first];u++)
              //  chmax(move1[u][nrm2[from[i].second]], c[i]);
            baga1[nrm1[from[i].first]][nrm2[from[i].second]].push_back(c[i]);
            scoate1[nrm1[to[i].first]][nrm2[from[i].second]].push_back(c[i]);
        }
    }

    for(int i=1;i<=cate1;i++)
    {
        multiset<int> s;
        for(int j=1;j<=cate2;j++)
        {
            for(int x:baga2[i][j])
                s.insert(x);
            for(int x:scoate2[i][j])
                s.erase(s.find(x));

            if(!s.empty())
                move2[i][j] = (*s.rbegin());
        }
    }

    for(int i=1;i<=cate2;i++)
    {
        multiset<int> s;
        for(int j=1;j<=cate1;j++)
        {
            for(int x:baga1[j][i])
                s.insert(x);
            for(int x:scoate1[j][i])
                s.erase(s.find(x));

            if(!s.empty())
                move1[j][i] = (*s.rbegin());
        }
    }

    for(int i=cate1;i>=1;i--)
    {
        for(int j=cate2;j>=1;j--)
        {
            chmax(dp[i][j], dp[i + 1][j] + move1[i][j] * (inv1[i + 1] - inv1[i]));
            chmax(dp[i][j], dp[i][j + 1] + move2[i][j] * (inv2[j + 1] - inv2[j]));
        }
    }
}

int qpoz[MAXQ], qt[MAXQ], rez[MAXQ];
pair<int,int> init[MAXQ];

void solve_queries()
{
    for(int i=1;i<=q;i++)
    {
        rez[i] = dp[nrm1[init[i].first]][nrm2[init[i].second]];
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i]>>a[i]>>b[i]>>c[i];
        from[i] = {t[i] - a[i], t[i] + a[i]};

        int end_t = t[i] + abs(a[i] - b[i]);
        to[i] = {end_t - b[i], end_t + b[i]};

        mp1[from[i].first]++;
        mp2[from[i].second]++;

        mp1[to[i].first]++;
        mp2[to[i].second]++;
    }

    for(int i=1;i<=q;i++)
    {
        cin>>qt[i]>>qpoz[i];
        init[i] = {qt[i] - qpoz[i], qt[i] + qpoz[i]};

        mp1[init[i].first]++;
        mp2[init[i].second]++;
    }

    for(auto it:mp1)
    {
        nrm1[it.first] = ++cate1;
        inv1[cate1] = it.first;
    }
    for(auto it:mp2)
    {
        nrm2[it.first] = ++cate2;
        inv2[cate2] = it.first;
    }

    precalc();

    solve_queries();

    for(int i=1;i<=q;i++)
        cout<<rez[i]/2<<"\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccm0laWP.o: in function `__tcf_0':
bodyguard.cpp:(.text+0x248): relocation truncated to fit: R_X86_64_PC32 against symbol `baga1' defined in .bss section in /tmp/ccm0laWP.o
/tmp/ccm0laWP.o: in function `precalc()':
bodyguard.cpp:(.text+0x52b): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x53d): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x545): relocation truncated to fit: R_X86_64_PC32 against symbol `from' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x563): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x590): relocation truncated to fit: R_X86_64_PC32 against symbol `nrm1' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x5a3): relocation truncated to fit: R_X86_64_PC32 against symbol `nrm2' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x5c8): relocation truncated to fit: R_X86_64_PC32 against symbol `baga1' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x5f3): relocation truncated to fit: R_X86_64_PC32 against symbol `nrm1' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x602): relocation truncated to fit: R_X86_64_PC32 against symbol `nrm2' defined in .bss section in /tmp/ccm0laWP.o
bodyguard.cpp:(.text+0x65f): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status