# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321683 | 2020-11-13T03:26:29 Z | daniel920712 | Soccer (JOI17_soccer) | C++14 | 2 ms | 492 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 492 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Incorrect | 2 ms | 492 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |