201,600-degree star Supplement preface

Source: Internet
Author: User

2016 "Baidu Star"-Rematch (Astar Round3)

Take Pictures

Idea: first project all the line segments to the x-axis, and then put the end coordinates of all the segments into an array, sorted and enumerated from the smallest start of the coordinates. If a start sign is encountered, add one; end point sign minus one. This allows you to find out how many segments are included in the same moment when you encounter the end point of the current segment

/************************************************************** problem:hdu 5417 user:youmi language:c++ R esult:accepted time:1591ms memory:1816k****************************************************************///#pragma COMMENT (linker, "/stack:1024000000,1024000000")//#include <bits/stdc++.h>#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>#include<stack>#include<Set>#include<sstream>#include<cmath>#include<queue>#include<deque>#include<string>#include<vector>#defineZeros (a) memset (A,0,sizeof (a))#defineOnes (a) memset (A,-1,sizeof (a))#defineSC (a) scanf ("%d", &a)#defineSC2 (A, b) scanf ("%d%d", &a,&b)#defineSC3 (a,b,c) scanf ("%d%d%d", &a,&b,&c)#defineSCS (a) scanf ("%s", a)#defineSclld (a) scanf ("%i64d", &a)#definePT (a) printf ("%d\n", a)#definePtlld (a) printf ("%i64d\n", a)#defineRep (i,from,to) for (int i=from;i<=to;i++)#defineIrep (I,to,from) for (int i=to;i>=from;i--)#defineMax (a) (a) > (b)? ( A):(B))#defineMin (a) < (b) ( A):(B))#defineLson (step<<1)#defineRson (lson+1)#defineEPS 1e-6#defineOO 0x3fffffff#defineTEST cout<< "*************************" <<endlConst DoublePi=4*atan (1.0);using namespaceStd;typedefLong LongLl;inlineintRead () {intx=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9') {if(ch=='-') f=-1; Ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; Ch=GetChar ();} returnx*F;}Const intmaxn=20000+Ten;intN,cnt,x,y,z,d,po,lmax,l,r,ans;structdata{intx, Y, Z;} A[MAXN];BOOLCMP (data a,data b) {if(a.x!=b.x)returna.x<b.x; Else    {        if(A.Y!=B.Y)returna.y<b.y;Else returna.z<b.z; }}intMain () {#ifndef Online_judge freopen ("In.txt","R", stdin); #endif    intt_t; scanf ("%d",&t_t);  for(intKase=1; kase<=t_t;kase++) {n=read (); Cnt=0;  for(intI=1; i<=n;i++) {x=read (), Y=read (), Z=read (), d=read (); if(y-x<=2*z) {if(d==1) po=0;Elsepo=1; a[++cnt].x=y-z; a[cnt].y=0; a[cnt].z=PO; a[++cnt].x=x+z; a[cnt].y=1; a[cnt].z=PO; }} sort (a+1, a+cnt+1, CMP); Lmax=l=r=ans=0;  for(intI=1; i<=cnt;i++)        {            if(a[i].z==0)            {                if(a[i].y==0) ++l;Else--l; }            Else            {                if(a[i].y==0) ++r;Else--R; }            if(L>lmax) lmax=l; if(Lmax+r>ans) ans=lmax+R; } printf ("Case #%d:\n%d\n", Kase,ans); }    return 0;}
View Code

2016 "Baidu Star"-Preliminary round (Astar round2a)

1001 All X

Idea: x* (10n-1)/9, after the should be simple

1002 Sitting in line

This has been written in the blog, so the title has been connected to the written blog.

1005 BD String

Ideas:

1---B

BBD 2---

3---bbd| B| Bdd

4---bbd| B| bdd| B| bbd| D| Bdd

5---bbd| B| bdd| B| bbd| D| bdd| B| bbd| B| bdd| D| bbd| D| Bdd

From the fifth line can see the law: every 8 for a group, wherein BBD,BDD continuous repetition, 4 in multiples of the corresponding letter, but also the occurrence of the law, then this part of the DFS can be; then for parts less than or equal to 8, you can use an array preprocessing.

Note: (Parts less than or equal to 8) and (multiples of 4) are calculated once at position 4, so remove this part

/************************************************************** problem:hdu 5694 user:youmi language:c++ R esult:accepted time:0ms memory:1572k****************************************************************///#pragma COMMENT (linker, "/stack:1024000000,1024000000")//#include <bits/stdc++.h>#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>#include<stack>#include<Set>#include<sstream>#include<cmath>#include<queue>#include<deque>#include<string>#include<vector>#defineZeros (a) memset (A,0,sizeof (a))#defineOnes (a) memset (A,-1,sizeof (a))#defineSC (a) scanf ("%d", &a)#defineSC2 (A, b) scanf ("%d%d", &a,&b)#defineSC3 (a,b,c) scanf ("%d%d%d", &a,&b,&c)#defineSCS (a) scanf ("%s", a)#defineSclld (a) scanf ("%i64d", &a)#definePT (a) printf ("%d\n", a)#definePtlld (a) printf ("%i64d\n", a)#defineRep (i,from,to) for (int i=from;i<=to;i++)#defineIrep (I,to,from) for (int i=to;i>=from;i--)#defineMax (a) (a) > (b)? ( A):(B))#defineMin (a) < (b) ( A):(B))#defineLson (step<<1)#defineRson (lson+1)#defineEPS 1e-6#defineOO 0x3fffffff#defineTEST cout<< "*************************" <<endlConst DoublePi=4*atan (1.0);using namespaceStd;typedefLong Longll;inline ll Read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9') {if(ch=='-') f=-1; Ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; Ch=GetChar ();} returnx*F;}intb[]={0,1,2,2,0,3,3,3,0};ll Sovle (ll tt) {if(tt==0)        return 0; ll ans=0; Ans+=sovle (tt/4); if(tt<4)        returnB[TT]; Else if(tt<8)    {        if(tt==4)            returnans+b[3]; Else            returnans+B[TT]; } ans+=3* (tt/8); Ans+=sovle (tt%8); if(tt%8>=4) ans-=1; returnans;}intMain () {#ifndef Online_judge freopen ("In.txt","R", stdin); #endif    intt_t; scanf ("%d",&t_t);  for(intKase=1; kase<=t_t;kase++) {ll l,r; L=read (), r=read (); ll ans=Sovle (R); Ans-=sovle (l1);    Ptlld (ANS); }}
View Code

1006 Gym Class

This is also in the 01 dynamic planning of the first question has been summed up, so here also directly link to the corresponding blog

201,600-degree star Supplement preface

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.