赛码"BestCoder"杯中国大学生程序设计冠军赛1001——Movie
2015-05-05 13:53
375 查看
Problem Description
Cloud and Miceren like watching movies.
Today, they want to choose some wonderful scenes from a movie. A movie has N scenes can be chosen, and each scene is associate with an interval [L, R]. L is the beginning time of the scene and R is the ending time. However, they can't choose two 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 that any pair of them do not overlap?
Since there are so many scenes that you can't get them in time, we will give you seven parameters N, L1, R1, a, b, c, d, and you can generate L1 ~ 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 integers N, L1, R1, a, b, c, d, meaning that there are N scenes. The i-th scene's interval is [Li, Ri]. L1 and R1 have been stated in input, and Li = (Li−1 ∗ a + b) mod 4294967296, Ri = (Ri−1 ∗ c + d) mod 4294967296.
After all the intervals are generated, swap the i-th interval's Li and Ri if Li > Ri.
T is about 100.
1 ≤ N ≤ 10000000.
1 ≤ L1,R1 ≤ 2000000000.
1 ≤ a,b,c,d ≤ 1000000000.
The ratio of test cases with N > 100 is less than 5%.
Output
For each test, print one line.
If they can choose such three scenes, output "YES", otherwise output "NO".
Sample Input
Sample Output
Cloud and Miceren like watching movies.
Today, they want to choose some wonderful scenes from a movie. A movie has N scenes can be chosen, and each scene is associate with an interval [L, R]. L is the beginning time of the scene and R is the ending time. However, they can't choose two 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 that any pair of them do not overlap?
Since there are so many scenes that you can't get them in time, we will give you seven parameters N, L1, R1, a, b, c, d, and you can generate L1 ~ 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 integers N, L1, R1, a, b, c, d, meaning that there are N scenes. The i-th scene's interval is [Li, Ri]. L1 and R1 have been stated in input, and Li = (Li−1 ∗ a + b) mod 4294967296, Ri = (Ri−1 ∗ c + d) mod 4294967296.
After all the intervals are generated, swap the i-th interval's Li and Ri if Li > Ri.
T is about 100.
1 ≤ N ≤ 10000000.
1 ≤ L1,R1 ≤ 2000000000.
1 ≤ a,b,c,d ≤ 1000000000.
The ratio of test cases with N > 100 is less than 5%.
Output
For each test, print one line.
If they can choose such three scenes, output "YES", otherwise output "NO".
Sample Input
2 3 1 4 1 1 1 1 3 1 4 4 1 4 1
Sample Output
NO YES 大意:大水。。问是否存在三个区间满足不重叠
#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; }
相关文章推荐
- 赛码"BestCoder"杯中国大学生程序设计冠军赛1009——邻接表+并查集——Exploration
- 赛码"BestCoder"杯中国大学生程序设计冠军赛
- 赛码"BestCoder"杯中国大学生程序设计冠军赛1005——DP——Game
- (赛码"BestCoder"杯中国大学生程序设计冠军赛)GCD
- "BestCoder"杯中国大学生程序设计冠军赛 HDU 5221 Occupation
- 个人训练记录-赛码"bestcoder"杯中国大学生程序设计冠军赛
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:H—Highway
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Partial Sum
- HDU 6152 2017中国大学生程序设计大赛网络赛 1003
- 中国(北方)大学生程序设计训练赛(第一周) (D E)
- 矩阵快速幂-中国(北方)大学生程序设计训练赛(第一周)Water Problem
- 中国(北方)大学生程序设计训练赛(第二周) (A B D G)
- ACM/ICPC中国•辽宁省第二届大学生程序设计竞赛通知
- XTU 1268 Strange Optimization 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南)
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Strange Optimization
- xtu 1260 Determinant [2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛(湖南) A]
- 中国(北方)大学生程序设计训练赛(第一周)-D (二分)
- 中国(北方)大学生程序设计训练赛(第二周)(Problem A: Common Substrings-hash)
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:E—Partial Sum
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Highway