Submission #64733


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
void load(int x,int y);
signed main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int x0,y0,x1,y1;
vector<vector<double>> dp(500,vector<double>(500,1e9));
cin>>x0>>y0>>x1>>y1;
if(x0>x1){
x0=0-x0+1;
x1=0-x1+1;
}
if(y0>y1){
y0=0-y0+1;
y1=0-y1+1;
}
if(x0<0){
int dx=x0/2*2-2;
x0-=dx;
x1-=dx;
}
if(y0<0){
int dy=y0/2*2-2;
y0-=dy;
y1-=dy;
}
dp[x0][y0] = 0;
int l=310;
for(int x=0;x<l;x++){
for(int y=0;y<l;y++){
dp[x+1][y]=min(dp[x+1][y],dp[x][y]+1);
dp[x][y+1]=min(dp[x][y+1],dp[x][y]+1);
if(x%2==1){
for(int ny=y+1;ny<l;ny++){
dp[x+1][ny]=min(dp[x+1][ny],dp[x][y]+sqrt(1+(ny-y)*(ny-y)));
}
}
if(y%2==1){
for(int nx=x+1;nx<l;nx++){
dp[nx][y+1]=min(dp[nx][y+1],dp[x][y]+sqrt((nx-x)*(nx-x)+1));
}
}
}
}
cout<<fixed<<setprecision(8)<<dp[x1][y1]<<'\n';
return 0;
}

ステータス

項目 データ
問題 1445 - 倉庫番ロボット
ユーザー名 syoribu
投稿日時 2020-11-15 22:38:52
言語 C++17
状態 Accepted
得点 10
ソースコード長 1208 Byte
最大実行時間 118 ms
最大メモリ使用量 2748 KB

セット

セット 得点 Cases
1 ALL 10 / 10 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1 AC 106 ms 2520 KB
1
in2 AC 109 ms 2576 KB
1
in3 AC 111 ms 2492 KB
1
in4 AC 104 ms 2548 KB
1
in5 AC 105 ms 2696 KB
1
in6 AC 110 ms 2728 KB
1
in7 AC 109 ms 2624 KB
1
in8 AC 104 ms 2652 KB
1
in9 AC 107 ms 2676 KB
1
in10 AC 118 ms 2548 KB
1
in11 AC 114 ms 2324 KB
1
in12 AC 103 ms 2352 KB
1
in13 AC 108 ms 2380 KB
1
in14 AC 107 ms 2408 KB
1
in15 AC 104 ms 2436 KB
1
in16 AC 103 ms 2464 KB
1
in17 AC 108 ms 2492 KB
1
in18 AC 104 ms 2520 KB
1
in19 AC 102 ms 2544 KB
1
in20 AC 100 ms 2608 KB
1
in21 AC 108 ms 2504 KB
1
in22 AC 105 ms 2532 KB
1
in23 AC 110 ms 2684 KB
1
in24 AC 105 ms 2708 KB
1
in25 AC 99 ms 2604 KB
1
in26 AC 108 ms 2636 KB
1
in27 AC 107 ms 2408 KB
1
in28 AC 113 ms 2568 KB
1
in29 AC 105 ms 2464 KB
1
in30 AC 108 ms 2524 KB
1
in31 AC 111 ms 2552 KB
1
in32 AC 110 ms 2452 KB
1
in33 AC 103 ms 2484 KB
1
in34 AC 101 ms 2512 KB
1
in35 AC 107 ms 2540 KB
1
in36 AC 113 ms 2564 KB
1
in37 AC 101 ms 2592 KB
1
in38 AC 103 ms 2748 KB
1
in39 AC 106 ms 2520 KB
1
in40 AC 107 ms 2704 KB
1
in41 AC 105 ms 2472 KB
1
in42 AC 106 ms 2504 KB
1
in43 AC 98 ms 2660 KB
1
in44 AC 109 ms 2560 KB
1
in45 AC 105 ms 2588 KB
1
in46 AC 106 ms 2616 KB
1
in47 AC 110 ms 2640 KB
1
in48 AC 101 ms 2668 KB
1