Bzoj 2732: [HNOI2012] Archery

Source: Internet
Author: User

2732: [HNOI2012] Archery time limit:10 Sec Memory limit:128 MB
submit:2532 solved:849
[Submit] [Status] [Discuss] Description

Mo Mo recently played a two-dimensional archery game, as shown in 1, the x-axis of this game in the ground, in the first quadrant there are some vertical line segments as targets, any two targets have no public parts, and do not touch the axis. The foam controls an archer located at (0,0), capable of firing an arrow of light with penetrating power at any angle from 0 to 90, excluding 0 and 90 degrees. Because there is no air resistance in the game, and the arrow does not have an arrow, the trajectory of the arrow will be a standard parabola, and all the targets that have been crossed by the trajectory are thought to have been shot by the foam, including those targeted at the end of the shot. This game has a variety of modes, in which Mo mo favorite is the mode of the rush. In the level mode, the first level only a target, hit the target can enter the second level, then on the basis of the first off will appear another target, if you can with stone shot these two targets can enter the third level, then there will be a third target. And so on, every pass will be a new target, in the K-off must be an arrow shot before the K-off all the K target to enter the K+1, otherwise the game is over. Mo Mo spent a lot of time in this game, but can only play to the seventh off "Seven Stars alignment", which makes her very confused. So she managed to get the position of each target and wanted you to tell her how much she could pass.

Input

Input file The first line is a positive integer n, which indicates a total of n-off. Then there are n rows, and the i+1 line is three positive integers separated by spaces Xi,yi1,yi2 (YI1<YI2), which indicates that the horizontal axis of the target appearing on the I-off is XI, and the ordinate range is from yi1 to Yi2.
The input ensures that 30% of the data satisfies the n≤100,50% data satisfies the n≤5000,100% data satisfies the n≤100000 and the given coordinates are not more than 109.

Output


Contains only an integer that represents the maximum number of customs clearance.

Sample Input5
2 8 12
5 4 5
3 8 10
6 2 3
1 3 7
Sample Output3
HINT



Data has been strengthened by WWT15. Special Acknowledgement! ---2015.03.09

Source

Day2

[Submit] [Status] [Discuss]

Semi-planar nude (almost), is inexplicable WA, disgusting, really disgusting, truly disgusting.

#include <cmath>#include<cstdio>#include<cstring>#include<algorithm>Const intSiz =510000;Const DoubleEPS = 1e-Ten;Const DoubleINF = 1e+ the;Const DoublePi = ACOs (-1); inlineintDCMP (Doublex) {    if(Fabs (x) <EPS)return 0; if(X >EPS)return 1; return-1;}structpair{Doublex, y; Pair (void) {}; Pair (DoubleADoubleb): X (a), Y (b) {};}; Pairoperator+(pair A, pair B) {returnPair (a.x + b.x, A.Y +b.y);} Pairoperator-(pair A, pair B) {returnPair (a.x-b.x, A.Y-b.y);} Pairoperator* (Pair A,Doubleb) {    returnPair (a.x * B, A.Y *b);}DoubleCross (pair A, pair B) {returna.x * B.Y-A.Y *b.x;}structline{intID;    Pair P, V; DoubleAlpha; Line (void) {}; Line (pair A, pair B,inti): P (a), V (b), id (i) {Alpha=atan2 (V.Y, v.x); if(Alpha <0) Alpha + +2*Pi; }};BOOL operator<(line A, line B) {returnA.alpha <B.alpha;} Pair Intersec (line A, line B) {pair U= A.P-B.P; Doublet = Cross (B.V, u)/Cross (A.V, B.V); returnA.P + A.V *t;}BOOLRight (pair A, line B) {returnCross (B.V, A-B.P) <0;}intn, tot;intHD, Tl;line s[siz];line Q[siz];p air p[siz];inlinevoidInsert (line l) { while(HD < TL && Right (P[TL-1], L)--tl;  while(HD < TL && Right (P[HD], L) + +HD; q[++TL] =l; if(HD < TL &&!dcmp (Q[TL].ALPHA-Q[TL-1].alpha))--tl; if(HD < TL) P[TL-1] = Intersec (Q[tl], Q[TL-1]);} InlineBOOLCheckintmid) {HD=1, TL =0;  for(inti =1; I <= tot; ++i)if(S[i].id <=mid) Insert (S[i]);  while(HD < TL && Right (P[TL-1], Q[HD])--tl; returnTL-HD >1;} Signed Main (void) {scanf ("%d", &N); s[++tot] = line (pair (+inf, +inf), pair (-1,0),0); s[++tot] = line (pair (-inf, +inf), pair (0, -1),0); s[++tot] = line (pair (-inf,-inf), pair (+1,0),0); s[++tot] = line (pair (+inf,-inf), pair (0, +1),0);  for(inti =1; I <= N; ++i) {Doublex, a, B; scanf ("%LF%LF%LF", &x, &a, &b); s[++tot] = line (pair (0, a/x), pair (1, -x), i); s[++tot] = line (pair (0, b/x), pair (-1, x), i); } std::sort (S+1, S + tot +1); intlt =1, RT = N, Mid, ans =0;  while(LT <=RT) {        if(Check (mid = (lt + rt) >>1)) Lt= Mid +1, ans =mid; ElseRT= Mid-1; } printf ("%d\n", ans);}

If you do not join 4 lines, the odd two points can also be stuck in the past, inexplicably ...

@Author: Yousiki

Bzoj 2732: [HNOI2012] Archery

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.