Topic Link ~~>
Mood: when the last bit of egg pain, processing points of the coordinate processing dizzy. So~ after the game sober a bit on AC.
Problem Solving Ideas:
State compression DP, with only 20 points. Let's say there are only a few sequential questions when arranging the lights. Fully able to use state compression to hand out, just to deal with the coordinates of the point when it is very troublesome, clear the idea of good.
state equation: dp [S | (1 << i)] = Max (dp[s | (1 << i)], dp[S] + W) , in the case of State s and then add I point (s in the previous without I point), so the update is OK.
Code (a bit of a setback):
#include <iostream> #include <sstream> #include <map> #include <cmath> #include <fstream> #include <queue> #include <vector> #include <sstream> #include <cstring> #include <cstdio > #include <stack> #include <bitset> #include <ctime> #include <string> #include <iomanip > #include <algorithm>using namespace std; #define INT __int64const double INF = 99999999; Const DOUBLE ESP = 0.00 00000001; const double PI = ACOs ( -1.0); const int MY = 100000 + 5; const int MX = (1<<20) + 5; int n;d ouble St, SD , Dp[mx], ans; struct node{double x, y, Z;} TX[100];d ouble CT (double x, int i) {double sx = tx[i].x, sy = TX[I].Y; Double SA = tx[i].z; Angle double dis = sqrt ((sx-x) * (sx-x) +sy*sy); Double A = sa*pi/(180*1.0), B, L, L1, C; if (SX = = x)//assumed to be above {if (a = = pi/2.0) return ans; else return SY * TAN (a); } else if (x < SX)//on the right {double ex = ACOs (Sy/dis) ; if (ex = = a)//exactly return L = Dis*sin (a); else if (a < ex)//is less than {b = asin (SY/DIS);//degree number L = Dis*cos (b); A = a + B; L = L-sy/tan (a); } else {c = ACOs (Sy/dis); L1 = Dis*sin (c); c = a-c; L = L1 + Sy*tan (c); } return L; } else if (x > SX) {c = ACOs (Sy/dis); if (c + a > pi/2.0) return ans; else {a = a + C; L = Sy*tan (a); return L-dis*sin (c); }}}void DP () {for (int i = 0; i < (1<<n); ++i)//initialization assignment dp[i] = 1; for (int i = 0; i < n; ++i)//Initialize single dp[1<<i] = CT (st, i); for (int S = 0; S < (1<<n); ++s) for (int i = 0; i < n; ++i) if (! ( s& (1<<i)) && dp[s]! =-1) {if (dp[s| ( 1<<i)] = =-1) dp[s| ( 1<<i)] = dp[s] + CT (st+dp[s], i); Else dp[s| ( 1<<i)] = max (dp[s| ( 1<<i)], dp[s] + CT (st+dp[s], i)); } double Max = 0; for (int i = 0; i < (1<<n); ++i) max = max (max, dp[i]); if (Max >= sd-st) cout<<fixed<<setprecision (n) <<ans<<endl; else Cout<<fixed<<setprecision (<<max<<endl); int main () {while (~scanf ("%d%lf%lf", &n, &st, &sd)) {ans = sd-st; for (int i = 0; i < n; ++i) cin>>tx[i].x>>tx[i].y>>tx[i].z; DP (); } return 0;}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Codeforces 385 D Bear and Floodlight