2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest F. Friends
Three friends Alex, Dmitry and Petr want to go abroad for a better life. They start at 09:00 in the morning in their home city A and want to be in the foreign city B as soon as possible.
Alex wants to start immediately and decided to use a car and a highway. He has to drive directly to the customs point C, then spends Dminutes there to pass the customs, and then drives directly to the city B. He drives the car with a speed of V kilometers per hour.
Dmitry has bought an airplane ticket. His plane departs at time T from the city A and flies for some time F directly to the city B.
Petr felt adventurous, so he decided to take his neighbor's tractor and drive straight to the city B with a speed of W kilometers per hour. If Petr's path lies through the customs point C, he spends D minutes there to pass the customs too. Otherwise, he does not stop during the whole trip.
Now they wonder who will be the first in the city B and can cook a welcoming dinner for all of them. We assume that friends live on a plane, and the distance between points is the common Euclidean distance.
The first line of input contains six integers XA, YA, XB, YB, XC and YC, the coordinates in kilometers of cities A and B and the customs point C respectively (0 ≤ XA, YA, XB, YB, XC, YC ≤ 1000). It is guaranteed that the customs point C is closer to A than the city B and closer to B than the city A.
The second line contains two integers D and V, the time to pass the customs in minutes and the speed of Alex's car in kilometers per hour respectively (0 ≤ D ≤ 1000, 40 ≤ V ≤ 100).
The third line contains the departure time T and the duration F of Dmitry's flight, both in the format "HH:MM". It is guaranteed that the departure time is correct, later than 09:00 and earlier than 24:00. The flight duration is greater than 00:00 and less than 24:00.
The fourth line contains one integer W, the speed of Petr's tractor in kilometers per hour (10 ≤ W ≤ 50).
Output the name of the first friend in the city B. It is guaranteed that the absolute difference between arrival times for each pair of friends will be at least one second.
0 0 10 0 5 5
60 100
10:00 00:05
10
Petr
0 0 100 0 50 50
0 100
09:01 02:10
50
Alex
0 0 1000 0 500 500
0 100
10:00 02:10
33
Dmitry
题意:看题目吧
分析:就是暴力算出所有答案就可以了。
非常简单的暴力题。
1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <ctime> 6 #include <iostream> 7 #include <algorithm> 8 #include <map> 9 #include <set> 10 #include <vector> 11 #include <deque> 12 #include <queue> 13 using namespace std; 14 typedef long long LL; 15 typedef double DB; 16 #define Rep(i, n) for(int i = (0); i < (n); i++) 17 #define Repn(i, n) for(int i = (n)-1; i >= 0; i--) 18 #define For(i, s, t) for(int i = (s); i <= (t); i++) 19 #define Ford(i, t, s) for(int i = (t); i >= (s); i--) 20 #define rep(i, s, t) for(int i = (s); i < (t); i++) 21 #define repn(i, s, t) for(int i = (s)-1; i >= (t); i--) 22 #define MIT (2147483647) 23 #define MLL (1000000000000000000LL) 24 #define INF (1000000001) 25 #define mk make_pair 26 #define ft first 27 #define sd second 28 #define clr(x, y) (memset(x, y, sizeof(x))) 29 #define sqr(x) ((x)*(x)) 30 #define sz(x) ((int) (x).size()) 31 #define puf push_front 32 #define pub push_back 33 #define pof pop_front 34 #define pob pop_back 35 36 inline int Getint() 37 { 38 char Ch = ' '; 39 int Ret = 0; 40 while(!(Ch >= '0' && Ch <= '9')) Ch = getchar(); 41 while(Ch >= '0' && Ch <= '9') 42 { 43 Ret = Ret * 10 + Ch - '0'; 44 Ch = getchar(); 45 } 46 return Ret; 47 } 48 49 const DB Eps = 1e-7; 50 const string Name[] = { 51 "Alex", 52 "Dmitry", 53 "Petr"}; 54 struct Point 55 { 56 DB x, y; 57 58 inline void Read() 59 { 60 scanf("%lf%lf", &x, &y); 61 } 62 } A, B, C; 63 DB D, V, W; 64 DB Start, Cost; 65 DB Ans[3]; 66 67 inline void Input() 68 { 69 A.Read(); 70 B.Read(); 71 C.Read(); 72 73 scanf("%lf%lf", &D, &V); 74 D /= 60.0; 75 76 int x = Getint(); 77 Start = x; 78 x = Getint(); 79 Start += x / 60.0; 80 x = Getint(); 81 Cost = x; 82 x = Getint(); 83 Cost += x / 60.0; 84 85 scanf("%lf", &W); 86 } 87 88 inline DB Sqr(DB x) 89 { 90 return x * x; 91 } 92 93 inline DB Dist(const Point &A, const Point &B) 94 { 95 return sqrt(Sqr(A.x - B.x) + Sqr(A.y - B.y)); 96 } 97 98 inline DB Multi(const Point &O, const Point &A, const Point &B) 99 { 100 DB X1 = A.x - O.x, 101 X2 = B.x - O.x, 102 Y1 = A.y - O.y, 103 Y2 = B.y - O.y; 104 return X1 * Y2 - X2 * Y1; 105 } 106 107 inline void Solve() 108 { 109 Ans[0] = Ans[2] = 9.0; 110 Ans[1] = Start + Cost; 111 112 DB DAB = Dist(A, B); 113 Ans[2] += DAB / W; 114 if(fabs(Multi(A, B, C)) <= Eps) Ans[2] += D; 115 116 Ans[0] += D; 117 DB DAC = Dist(A, C), DCB = Dist(C, B); 118 Ans[0] += (DAC + DCB) / V; 119 120 int p = 0; 121 For(i, 1, 2) 122 if(Ans[i] < Ans[p]) p = i; 123 //Rep(i, 3) printf("%.3lf ", Ans[i]); 124 cout << Name[p] << endl; 125 } 126 127 int main() { 128 //freopen("F.in", "r", stdin); 129 Input(); 130 Solve(); 131 return 0; 132 }