답안 #955820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955820 2024-03-31T13:00:40 Z vjudge1 Pinball (JOI14_pinball) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
vector<tuple<long long,long long,long long,long long> > v;
long long n,m;
bool visited[1002][605][605];
long long dp[10002][605][605];
map<long long,long long> prevod;
bool gotovo=false;
long long p=1;

long long f(long long poz,long long l,long long r)
{
    //cout<< "poz = "<<poz<<" l="<<l<<" r="<<r<<endl;
    if (poz==-1)
    {
        if (l==1 && r==prevod[n])
        {
            gotovo=true;
            return 0;
        }
        return 1000000000000000;
    }
    if (visited[poz][l][r]) return dp[poz][l][r];

    long long op1=f(poz-1,l,r);
    long long op2=1000000000000000;

    long long a=get<0>(v[poz]),b=get<1>(v[poz]),c=get<2>(v[poz]);
    if (c>=l && c<=r) op2=f(poz-1,min(a,l),max(b,r))+get<3>(v[poz]);

    long long odg=min(op1,op2);
    visited[poz][l][r]=true;
    dp[poz][l][r]=odg;
    return odg;
}

int main()
{
    cin>>m>>n;

    vector<long long> pocetni;
    for (long long i=0;i<m;i++)
    {
        long long a,b,c,d;
        cin>>a>>b>>c>>d;
        pocetni.push_back(a);
        pocetni.push_back(b);
        pocetni.push_back(c);

        v.push_back({a,b,c,d});
    }

    sort(pocetni.begin(),pocetni.end());
    for (long long i=0;i<pocetni.size();i++)
    {
        long long x=pocetni[i];
        if (prevod[x]==0)
        {
            prevod[x]=p;
            p++;
        }
    }
    if (prevod[n]==0) prevod[n]=p;

    for (long long i=0;i<v.size();i++)
    {
        get<0>(v[i])=prevod[get<0>(v[i])];
        get<1>(v[i])=prevod[get<1>(v[i])];
        get<2>(v[i])=prevod[get<2>(v[i])];
    }

    long long odg=1000000000000000;
    for (long long i=m-1;i>=0;i--)
        odg = min(odg,get<3>(v[i])+f(i-1,get<0>(v[i]),get<1>(v[i])));

    if (gotovo==false || pocetni[0]!=1) odg=-1;
    cout<<odg<<endl;
    return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:55:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (long long i=0;i<pocetni.size();i++)
      |                        ~^~~~~~~~~~~~~~~
pinball.cpp:66:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for (long long i=0;i<v.size();i++)
      |                        ~^~~~~~~~~
/tmp/cc1L2aLM.o: in function `f(long long, long long, long long)':
pinball.cpp:(.text+0x48c): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text+0x4fe): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text+0x592): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text+0x5cf): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text+0x62d): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1L2aLM.o
/tmp/cc1L2aLM.o: in function `main':
pinball.cpp:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text.startup+0x10): 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/10/libstdc++.a(globals_io.o)
pinball.cpp:(.text.startup+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text.startup+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text.startup+0xe5): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cc1L2aLM.o
pinball.cpp:(.text.startup+0xec): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status