제출 #1342758

#제출 시각아이디문제언어결과실행 시간메모리
1342758valerianToy (CEOI24_toy)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl '\n'
#define Valerian void
#define Valerian_or_Habil ios::sync_with_stdio(false); cin.tie(0);

using namespace std;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int pref[305][305];
string g[305];

int get(int x1,int y1,int x2,int y2){
    return pref[y2][x2]
         - (x1?pref[y2][x1-1]:0)
         - (y1?pref[y1-1][x2]:0)
         + (x1&&y1?pref[y1-1][x1-1]:0);
}

int dista[305][305][305][305];

Valerian solve(){
    int W,H,K,L;
    cin>>W>>H>>K>>L;

    int hx,hy,vx,vy;
    cin>>hx>>hy>>vx>>vy;

    for(int i=0;i<H;i++) cin>>g[i];

    int tx=-1,ty=-1;
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            if(g[i][j]=='*') ty=i,tx=j;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            pref[i][j]=(g[i][j]=='X');
            if(i) pref[i][j]+=pref[i-1][j];
            if(j) pref[i][j]+=pref[i][j-1];
            if(i&&j) pref[i][j]-=pref[i-1][j-1];
        }
    }

    memset(dista,-1,sizeof(dista));

    queue<array<int,4>> q;
    q.push({hx,hy,vx,vy});
    dista[hx][hy][vx][vy]=0;

    while(!q.empty()){
        auto cur=q.front(); q.pop();
        int xh=cur[0], yh=cur[1], xv=cur[2], yv=cur[3];

        int cx=xv, cy=yh;
        if(cx==tx && cy==ty){
            cout<<"YES"<<endl;
            return;
        }

        for(int i=0;i<4;i++){
            int nxh=xh+dx[i], nyh=yh+dy[i];
            if(nxh>=0 && nxh+K-1<W && nyh>=0 && nyh<H){
                if(get(nxh,nyh,nxh+K-1,nyh)==0){
                    int ix=xv, iy=nyh;
                    if(ix>=nxh && ix<=nxh+K-1 && iy>=yv && iy<=yv+L-1){
                        if(dista[nxh][nyh][xv][yv]==-1){
                            dista[nxh][nyh][xv][yv]=1;
                            q.push({nxh,nyh,xv,yv});
                        }
                    }
                }
            }
        }

        for(int i=0;i<4;i++){
            int nxv=xv+dx[i], nyv=yv+dy[i];
            if(nxv>=0 && nxv<W && nyv>=0 && nyv+L-1<H){
                if(get(nxv,nyv,nxv,nyv+L-1)==0){
                    int ix=nxv, iy=yh;
                    if(ix>=xh && ix<=xh+K-1 && iy>=nyv && iy<=nyv+L-1){
                        if(dista[xh][yh][nxv][nyv]==-1){
                            dista[xh][yh][nxv][nyv]=1;
                            q.push({xh,yh,nxv,nyv});
                        }
                    }
                }
            }
        }
    }

    cout<<"NO"<<endl;
}

int main(){
    Valerian_or_Habil;
    solve();
}

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

/tmp/ccxxwIg3.o: in function `__tcf_0':
Main.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `g[abi:cxx11]' defined in .bss section in /tmp/ccxxwIg3.o
/tmp/ccxxwIg3.o: in function `get(int, int, int, int)':
Main.cpp:(.text+0x2dd): relocation truncated to fit: R_X86_64_PC32 against symbol `pref' defined in .bss section in /tmp/ccxxwIg3.o
/tmp/ccxxwIg3.o: in function `solve()':
Main.cpp:(.text+0x35d): 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/13/libstdc++.a(globals_io.o)
Main.cpp:(.text+0x3f6): relocation truncated to fit: R_X86_64_PC32 against symbol `g[abi:cxx11]' defined in .bss section in /tmp/ccxxwIg3.o
Main.cpp:(.text+0x42d): relocation truncated to fit: R_X86_64_PC32 against symbol `g[abi:cxx11]' defined in .bss section in /tmp/ccxxwIg3.o
Main.cpp:(.text+0x472): relocation truncated to fit: R_X86_64_PC32 against symbol `pref' defined in .bss section in /tmp/ccxxwIg3.o
Main.cpp:(.text+0x727): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
Main.cpp:(.text+0x742): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
Main.cpp:(.text+0x9b9): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
Main.cpp:(.text+0x9d4): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
/tmp/ccxxwIg3.o: in function `main':
Main.cpp:(.text.startup+0x12): 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