Submission #321683

#TimeUsernameProblemLanguageResultExecution timeMemory
321683daniel920712Soccer (JOI17_soccer)C++14
5 / 100
2 ms492 KiB
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <set> #include <map> #include <algorithm> #include <time.h> #include <algorithm> #include <queue> #include <utility> #include <map> using namespace std; long long x[1000005]; long long y[1000005]; map < pair < long long , pair < long long ,long long > > , long long > DP; long long N,A,B,C; long long F(long long here,long long xx,long long yy) { if(here==N) return 0; if(DP.find(make_pair(here,make_pair(xx,yy)))!=DP.end()) return DP[make_pair(here,make_pair(xx,yy))]; DP[make_pair(here,make_pair(xx,yy))]=(abs(xx-x[here])+abs(yy-y[here]))*C+min(min(C*abs(xx-x[here+1]) ,(xx!=x[here+1])*B)+F(here+1,x[here+1],yy),min(C*abs(yy-y[here+1]),(yy!=y[here+1])*B)+F(here+1,xx,y[here+1])); return DP[make_pair(here,make_pair(xx,yy))]; } int main() { long long H,W; long long i; scanf("%lld %lld",&H,&W); scanf("%lld %lld %lld",&A,&B,&C); scanf("%lld",&N); for(i=0;i<N;i++) scanf("%lld %lld",&x[i],&y[i]); if(N==2) printf("%lld\n",min(C*abs(y[1]-y[0])+min(C*abs(x[1]-x[0]),A*abs(x[1]-x[0])+B),C*abs(x[1]-x[0])+min(C*abs(y[1]-y[0]),A*abs(y[1]-y[0])+B))); else { printf("%lld\n",F(0,x[0],y[0])); } return 0; }

Compilation message (stderr)

soccer.cpp: In function 'int main()':
soccer.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     scanf("%lld %lld",&H,&W);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
soccer.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |     scanf("%lld %lld %lld",&A,&B,&C);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
soccer.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |     scanf("%lld",&N);
      |     ~~~~~^~~~~~~~~~~
soccer.cpp:34:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     for(i=0;i<N;i++) scanf("%lld %lld",&x[i],&y[i]);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...