HDU 5214 Movie (competition code & quot; BestCoder & quot; cup of question A of the Chinese College Students' Program Design Championship)

Source: Internet
Author: User

HDU 5214 Movie (competition code "BestCoder" cup Chinese College Students' Program Design champion)

On May Day, I had the honor to go to hangdian with my teacher to seek abuse, wait for the great AK of Tsinghua University and other giants, sum up experience, and inspire me to move forward!

[Question link]Click here ~~

Theme] In multiple uncertain intervals, I asked if I could select three different intervals.

Solutions]

Ps: At that time, it was the hjs question. After the question was knocked out, all three people checked it and found that there was no problem, but the question was handed in with CE, followed by various calls and errors, finally, we found that the modulo was removed, and it was a tragedy to determine whether a certain interval exists in the middle of an existing interval without crossover...

[Official solution report] First, we should consider how to select the leftmost interval. If the leftmost interval is I, the left endpoint of the other two intervals must be greater than Ri, if j exists outside of I The modulo value of this question is very special. The natural overflow of unsigned int can achieve the same effect, and the time complexity O (N)

Code:

 

# Include
 
  
Using namespace std; const int N = 1e7 + 10; const int inf = 0x3f3f3f; struct node {unsigned int pre, last;} Map [N]; int main () {int T, n; unsigned int L1, R1, a, B, c, d, maxx, minn; bool flag; scanf ("% d", & T ); while (T --) {flag = false; cin> n> L1> R1> a> B> c> d; maxx = 0; minn = inf; Map [0]. pre = L1; Map [0]. last = R1; for (int I = 1; I
  
   
Map [I]. last) swap (Map [I]. pre, Map [I]. last); // switch after all processing! If (Map [I]. pre> maxx) maxx = Map [I]. pre; // the maximum range of the Left endpoint is used as the rightmost range. if (Map [I]. last
   
    
Minn) {puts ("YES"); flag = true; break ;}} if (! Flag) puts ("NO");} return 0 ;}
   
  
 


 

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.