Submission #1795532
Source Code Expand
#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; }
Submission Info
Submission Time | |
---|---|
Task | C - Fountain Walk |
User | HPaddy |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2891 Byte |
Status | CE |
Compile Error
/tmp/ccHiZU7c.o: In function `rec(int, int, int, double)': Main.cpp:(.text+0x18): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `gx' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `gy' defined in .bss section in /tmp/ccHiZU7c.o /tmp/ccHiZU7c.o: In function `main': Main.cpp:(.text.startup+0x2): relocation truncated to fit: R_X86_64_32 against symbol `sx' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(.text.startup+0x11): relocation truncated to fit: R_X86_64_32 against symbol `sy' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(.text.startup+0x1e): relocation truncated to fit: R_X86_64_32 against symbol `gx' defined in .bss section in /tmp/ccHiZU7c.o Main.cpp:(...