Problem Description
Cloud and miceren like watching movies.
Today, they want to choose some wonderful scenes from a movie. A movie hasNScenes can chosen, and each scene was associate with an interval [L,< Span id= "mathjax-span-8" class= "Mrow" >r ]. L is The beginning time of the scene And r is the ending time. However, they can ' t choose and scenes which have overlapping intervals. (for example, scene with [1, 2] and scene with [2, 3], scene with [2, 5] and Scene with[3, 4]).
Now, can-you-tell them if they can choose such three scenes so any pair of them does not overlap?
Since There is so many scenes that's can ' t get them in time, we'll give you seven parametersN, l 1, r1 , a, b, c, d , and you can generateL1 ~LN , r1 ~ rN by these parameters.
Input
The first line contains a single integer T, indicating the number of test cases.
Each test case contains seven integersN, l 1, r1 , a, b, c, d , meaning that there isNScenes. The i-th scene ' s interval is [Li, Ri ].L1 andR1 has been stated in input, andLI=(LI−1∗A+B)MOD 4294967296,RI=(Ri−1 ∗ c + d) mod 4294967296 .
After all the intervals is generated, swap the i-th interval ' sLi andri If li > ri .
T is about 100.
1 ≤ N ≤ 10000000.
1 ≤ l1,< Span id= "mathjax-span-219" class= "Msubsup" >r1 ≤ 2000000000 .
1 ≤ a,b,< Span id= "mathjax-span-236" class= "Mi" >c d ≤ 1000000000 .
The ratio of test cases with N > are less than 5%.
Output
For each test, print one line.
If They can choose such three scenes, output "YES", otherwise output "NO".
Sample Input
23 1 4 1 1 1 13 1 4 4 1 4 1
Sample Output
NOYES
The main idea: flood. Ask if there are three intervals to meet non-overlapping
#include <cstdio> #include <cstring> #include <algorithm>using namespace std;const int MAX = 10000000+ 10;const int inf = 0x3f3f3f3f;struct edge{unsigned int l,r;} T[max];int Main () {int t,n; unsigned int A, B, C, D; scanf ("%d", &t); while (t--) {scanf ("%d%d%d%d%d%d%d", &n,&t[1].l,&t[1].r,&a,&b,&c,&d); for (int i = 2; I <= n; i++) {t[i].l = t[i-1].l*a + b; T[I].R = t[i-1].r*c + D; } for (int i = 1; I <= n; i++) {if (T[i].l > T[I].R) swap (T[I].L,T[I].R); } unsigned int min1 = 4294967295UL,MAX1 = 0; for (int i = 1; I <= n; i++) {if (T[I].R < min1) min1 = T[I].R; if (T[i].l > max1) max1 = T[I].L; } if (Min1 > Max1) {printf ("no\n"); Continue } int flag = 0; for (int i = 1; I <= n; i++) {if (T[i].l >Min1 && T[I].R < max1) {printf ("yes\n"); flag = 1; Continue }} if (!flag) printf ("no\n"); } return 0;}
Race code "Bestcoder" Cup Chinese college students program Design championship 1001--movie