Topcoder-srm-613-div2

Source: Internet
Author: User
Tags acos bitset cmath

250 points:
Simple question, the number of the three characters of the C a T is OK

/************************************************************************* > File name:250.cpp > Author: ALex > Mail: [email protected] > Created time:2015 May 08 Friday 20:29 05 seconds ************************************ ************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;classtarostring { Public:stringGetanswer (stringSTR) {intn = str.length ();intCnt1 =0, Cnt2 =0, Cnt3 =0;intPOS1 =0, Pos2 =0, POS3 =0; for(inti =0; I < n; ++i) {if(Str[i] = =' C ') {++cnt1;                POS1 = i; }Else if(Str[i] = =' A ') {++cnt2;                Pos2 = i; }Else if(Str[i] = =' T ') {++cnt3;                POS3 = i; }            }if(Cnt1! =1|| Cnt2! =1|| Cnt3! =1) {return "Impossible"; }if(Pos1 < Pos2 && Pos2 < POS3) {return "Possible"; }return "Impossible"; }};

500 points:
Violence enumerates the leftmost, then the smallest right end
All to the left and all to the right also to consider

/************************************************************************* > File name:500.cpp > Author: ALex > Mail: [email protected] > Created time:2015 May 08 Friday 20:37 19 seconds ************************************ ************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> Pint;classTarofriends { Public:intGetNumber ( vector <int>ArrintX) {intn = arr.size ();if(n = =1) {return 0; }intL, R;intAns = (1<< -); for(inti =0; I < n; ++i) { for(intSGN =0; SGN <2; ++SGN) {L = Arr[i];if(SGN)                    {L + = X; }Else{L-= X; } r =-(1<< -); for(intj =0; J < N; ++J) {if(j = = i) {Continue; }if(Arr[j]-x < l && Arr[j] + x < L) {r =-(1<< -); Break; }if(Arr[j]-X < L)                        {r = max (R, Arr[j] + X); }Else{r = max (R, Arr[j]-X); }                    }if(r = =-(1<< -)) {Continue;                } ans = min (ans, r-l); }            }returnAns }};

1000 points:
Dp[i][sta][k] Represents the enumeration to the I card, <=10 the number status of STA, a total of k different number of scenarios, transfer sub-I card to take or not take

/************************************************************************* > File name:1000.cpp > Author: ALex > Mail: [email protected] > Created time:2015 May 08 Friday 21:25 26 seconds *********************************** *************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL; LL dp[ -][1100][ the];classTarocards { Public: LL GetNumber ( vector <int>F vector <int>SintK) {intn = f.size (); for(inti =0; I <= N; ++i) { for(intj =0; J < (1<<Ten); ++J) { for(intK =0; K <= K; ++K) {Dp[i][j][k] =0; }}} dp[0][0][0] =1; for(inti =0; I < n; ++i) { for(intj =0; J < (1<<Ten); ++J) { for(intK =0; K <= K; ++K) {if(Dp[i][j][k]) {dp[i +1][j][k] + = dp[i][j][k];intNewsta = j;intKK = k;if(F[i] >Ten) {++kk; }Else if(! ((1<< (F[i]-1)) (& Newsta)) {++kk; Newsta |= (1<< ((f[i)-1))); }if(! ((1<< (S[i]-1)) (& Newsta)) {++kk; Newsta |= (1<< ((s[i)-1))); }if(KK > K) {Continue; } Dp[i +1][NEWSTA][KK] + = dp[i][j][k]; }}}} LL ans =0; for(inti =0; I < (1<<Ten); ++i) { for(intj =0; J <= K;                ++j) {ans + = dp[n][i][j]; }            }returnAns }};

Topcoder-srm-613-div2

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.