# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20911 | 2017-03-19T15:20:00 Z | model_code | Soccer (JOI17_soccer) | C++11 | 1503 ms | 45516 KB |
#include <cstdio> #include <vector> #include <queue> int H,W,N; long long A,B,C; int pos_h[100008]; int pos_w[100008]; int min_move_cost[508][508]; int queue_h[1000008]; int queue_w[1000008]; int adj_h[5]={0,-1,0,1}; int adj_w[5]={-1,0,1,0}; using namespace std; priority_queue <pair<long long,int>,vector<pair<long long,int> >,greater<pair<long long,int> > > pq; long long sol[508][508][5]; int main() { scanf("%d%d%lld%lld%lld%d",&H,&W,&A,&B,&C,&N); for(int i=0;i<N;i++) scanf("%d%d",&pos_h[i],&pos_w[i]); int qst,qls; qst=0; qls=N; //�앮쐿�� for(int i=0;i<=H;i++) for(int j=0;j<=W;j++) min_move_cost[i][j]=99999999; for(int i=0;i<N;i++) { queue_h[i]=pos_h[i]; queue_w[i]=pos_w[i]; min_move_cost[queue_h[i]][queue_w[i]]=0; } //亮끻꽛�덃렋榮㏂겎�쒌꺖�ャ굮�얇걚�ヨ죱�뤵궠�밤깉��츞�� while(qst<qls) { int new_c=min_move_cost[queue_h[qst]][queue_w[qst]]+1; for(int i=0;i<4;i++) { int new_h=queue_h[qst]+adj_h[i]; int new_w=queue_w[qst]+adj_w[i]; if(new_h<0||new_h>H) continue; if(new_w<0||new_w>W) continue; if(min_move_cost[new_h][new_w]<99999999) continue; min_move_cost[new_h][new_w]=new_c; queue_h[qls]=new_h; queue_w[qls++]=new_w; } qst++; } //�앮쐿�� long long INF=1000000007; INF*=INF; for(int i=0;i<=H;i++) for(int j=0;j<=W;j++) for(int k=0;k<5;k++) sol[i][j][k]=INF; //�묆걤(0節�4)*10^7 + �쀧㎉�뺠퇌�� * 5000 + �긺㎉�뺠퇌�� //����러�믦㎗�� pq.push(make_pair(0,pos_h[0]*5000+pos_w[0]+40000000)); while(pq.size()) { long long now_cost=pq.top().first; int now_temp=pq.top().second; int now_type=now_temp/10000000; now_temp%=10000000; int now_h=now_temp/5000; int now_w=now_temp%5000; pq.pop(); if(sol[now_h][now_w][now_type]<INF) continue; sol[now_h][now_w][now_type]=now_cost; if(now_type==4) { for(int i=0;i<4;i++) { int new_h=now_h+adj_h[i]; int new_w=now_w+adj_w[i]; if(new_h<0||new_h>H) continue; if(new_w<0||new_w>W) continue; pq.push(make_pair(now_cost+C,new_h*5000+new_w+40000000)); } for(int i=0;i<4;i++) { pq.push(make_pair(now_cost+B,now_h*5000+now_w+10000000*i)); } } else { pq.push(make_pair(now_cost+C*min_move_cost[now_h][now_w],now_h*5000+now_w+40000000)); int new_h=now_h+adj_h[now_type]; int new_w=now_w+adj_w[now_type]; if(new_h<0||new_h>H) continue; if(new_w<0||new_w>W) continue; pq.push(make_pair(now_cost+A,new_h*5000+new_w+10000000*now_type)); } } printf("%lld\n",sol[pos_h[N-1]][pos_w[N-1]][4]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 263 ms | 24012 KB | Output is correct |
2 | Correct | 0 ms | 20856 KB | Output is correct |
3 | Correct | 1116 ms | 33228 KB | Output is correct |
4 | Correct | 1169 ms | 45516 KB | Output is correct |
5 | Correct | 359 ms | 27084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1389 ms | 45516 KB | Output is correct |
2 | Correct | 1329 ms | 45516 KB | Output is correct |
3 | Correct | 916 ms | 33228 KB | Output is correct |
4 | Correct | 1029 ms | 33228 KB | Output is correct |
5 | Correct | 969 ms | 33228 KB | Output is correct |
6 | Correct | 1183 ms | 33228 KB | Output is correct |
7 | Correct | 1276 ms | 45516 KB | Output is correct |
8 | Correct | 1119 ms | 45516 KB | Output is correct |
9 | Correct | 1346 ms | 45516 KB | Output is correct |
10 | Correct | 153 ms | 27084 KB | Output is correct |
11 | Correct | 1333 ms | 45516 KB | Output is correct |
12 | Correct | 1386 ms | 45516 KB | Output is correct |
13 | Correct | 926 ms | 33228 KB | Output is correct |
14 | Correct | 1419 ms | 45516 KB | Output is correct |
15 | Correct | 1043 ms | 45516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 263 ms | 24012 KB | Output is correct |
2 | Correct | 0 ms | 20856 KB | Output is correct |
3 | Correct | 1116 ms | 33228 KB | Output is correct |
4 | Correct | 1169 ms | 45516 KB | Output is correct |
5 | Correct | 359 ms | 27084 KB | Output is correct |
6 | Correct | 1389 ms | 45516 KB | Output is correct |
7 | Correct | 1329 ms | 45516 KB | Output is correct |
8 | Correct | 916 ms | 33228 KB | Output is correct |
9 | Correct | 1029 ms | 33228 KB | Output is correct |
10 | Correct | 969 ms | 33228 KB | Output is correct |
11 | Correct | 1183 ms | 33228 KB | Output is correct |
12 | Correct | 1276 ms | 45516 KB | Output is correct |
13 | Correct | 1119 ms | 45516 KB | Output is correct |
14 | Correct | 1346 ms | 45516 KB | Output is correct |
15 | Correct | 153 ms | 27084 KB | Output is correct |
16 | Correct | 1333 ms | 45516 KB | Output is correct |
17 | Correct | 1386 ms | 45516 KB | Output is correct |
18 | Correct | 926 ms | 33228 KB | Output is correct |
19 | Correct | 1419 ms | 45516 KB | Output is correct |
20 | Correct | 1043 ms | 45516 KB | Output is correct |
21 | Correct | 309 ms | 24012 KB | Output is correct |
22 | Correct | 1416 ms | 33228 KB | Output is correct |
23 | Correct | 1293 ms | 33228 KB | Output is correct |
24 | Correct | 1496 ms | 33228 KB | Output is correct |
25 | Correct | 1189 ms | 33228 KB | Output is correct |
26 | Correct | 1156 ms | 33228 KB | Output is correct |
27 | Correct | 669 ms | 21324 KB | Output is correct |
28 | Correct | 786 ms | 21324 KB | Output is correct |
29 | Correct | 1176 ms | 27084 KB | Output is correct |
30 | Correct | 956 ms | 24012 KB | Output is correct |
31 | Correct | 1406 ms | 45516 KB | Output is correct |
32 | Correct | 1503 ms | 45516 KB | Output is correct |
33 | Correct | 1079 ms | 33228 KB | Output is correct |
34 | Correct | 1419 ms | 45516 KB | Output is correct |
35 | Correct | 749 ms | 21708 KB | Output is correct |