Codeforces 385 D bear and floodlight

Source: Internet
Author: User
Tags acos

Question link ~~>

Question recognition:At the end of the competition, it was a little painful, and the coordinates of the processing points were dizzy. So ~ After the game is fully awake, the AC will be connected.

Solution:

State compression DP, with only 20 points. If there are only different sequence problems during lamp arrangement, you can use state compression to recursion, but it is very troublesome to process the coordinates of the points, just clear your mind.

State equation: DP [S | (1 <I)] = max (DP [S | (1 <I)], DP [s] + W), In the case of status S, add the I point (the first in S does not include the I point), so that it is OK to keep updating.

Code (a little frustrated ):

# 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.0000000001; const double Pi = ACOs (-1.0); const int My = 100000 + 5; const int MX = (1 <20) + 5; int N; double St, SD, DP [MX], ans; struct node {Double X, y, Z;} TX [2, 100]; double 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) // if the return ANS is in the upper side {if (a = PI/2.0; else return Sy * Tan (a);} else if (x <SX) // on the right {Double EX = ACOs (SY/DIS); If (EX = A) // return L = Dis * sin (a); else if (a <ex) // less than {B = Asin (SY/DIS); // degree 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 (); return L-Dis * sin (c) ;}} void DP () {For (INT I = 0; I <(1 <n); ++ I) // initialize the value of DP [I] =-1; for (INT I = 0; I <n; ++ I) // initialize a 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 (12) <ans <Endl; else cout <fixed <setprecision (12) <max <Endl;} int main () {While (~ Scanf ("% d % 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 ;}

 

Codeforces 385 D bear and floodlight

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.