Language: C++

#include<iostream>
#include<iomanip>
#include<cmath>

int n,x,y,sx,sy,gx,gy;

double dp[100000000][100000000];

bool flag[100000000][100000000];

const double cir=3.14159265358979*5;

//direc 1右 2左 3上 4下 から 差が1なら半周 それ以外なら4分の1周

double rec(int direc,int nx,int ny,double len){
    
    double res=300000000;
    
    if(nx==gx&&ny==gy)
        res=len;
    
    else{
        if(flag[nx][ny]){
            if(nx<x){
                if(abs(direc-2)==1)
                res=rec(2,nx+1,ny,len+90+cir*2)<res?rec(2,nx+1,ny,len+90+cir*2):res;
                else
                res=rec(2,nx+1,ny,len+90+cir)<res?rec(2,nx+1,ny,len+90+cir):res;
            }
            if(0<nx){
                if(abs(direc-1)==1)
                    res=rec(1,nx-1,ny,len+90+cir*2)<res?rec(1,nx-1,ny,len+90+cir*2):res;
                else
                    res=rec(1,nx-1,ny,len+90+cir)<res?rec(1,nx-1,ny,len+90+cir):res;
            }
            if(ny<y){
                if(abs(direc-4)==1)
                    res=rec(4,nx,ny+1,len+90+cir*2)<res?rec(4,nx,ny+1,len+90+cir*2):res;
                else
                    res=rec(4,nx,ny+1,len+90+cir)<res?rec(4,nx,ny+1,len+90+cir):res;
            }
            if(0<ny){
                if(abs(direc-3)==1)
                    res=rec(3,nx,ny-1,len+90+cir*2)<res?rec(3,nx,ny-1,len+90+cir*2):res;
                else
                    res=rec(3,nx,ny-1,len+90+cir)<res?rec(3,nx,ny-1,len+90+cir):res;
            }
        }
        else{
            if(nx<x){
                if(flag[nx+1][ny])
                    res=rec(2,nx+1,ny,len+100)<res?rec(2,nx+1,ny,len+100):res;
                else
                    res=rec(2,nx+1,ny,len+90)<res?rec(2,nx+1,ny,len+90):res;
            }
            if(0<nx){
                if(flag[nx-1][ny])
                    res=rec(1,nx-1,ny,len+100)<res?rec(1,nx-1,ny,len+100):res;
                else
                    res=rec(1,nx-1,ny,len+90)<res?rec(1,nx-1,ny,len+90):res;
            }
            if(ny<y){
                if(flag[nx][ny+1])
                    res=rec(4,nx,ny+1,len+100)<res?rec(4,nx,ny+1,len+100):res;
                else
                    res=rec(4,nx,ny+1,len+90)<res?rec(4,nx,ny+1,len+90):res;
            }
            if(0<ny){
                if(flag[nx][ny-1])
                    res=rec(3,nx,ny-1,len+100)<res?rec(3,nx,ny-1,len+100):res;
                else
                    res=rec(3,nx,ny-1,len+90)<res?rec(3,nx,ny-1,len+90):res;
            }
        }
    }
    
    return res;
}

int main(){
    
    std::cin>>sx>>sy>>gx>>gy;
    
    std::cin>>n;
    
    for(int i=0;i<n;i++){
        std::cin>>x>>y;
        flag[x][y]=true;
    }
    
    std::cout<<std::setprecision(18)<<rec(0,sx,sy,0)<<std::endl;
    
    return 0;
}


Compiler output:
/tmp/cc8k1eET.o: in function `rec(int, int, int, double)':
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
a.cc:(.text+0x5ef): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
a.cc:(.text+0x724): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
a.cc:(.text+0x85e): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
a.cc:(.text+0x993): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
/tmp/cc8k1eET.o: in function `main':
a.cc:(.text+0xb79): relocation truncated to fit: R_X86_64_PC32 against symbol `flag' defined in .bss section in /tmp/cc8k1eET.o
collect2: error: ld returned 1 exit status