Movie

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.

 
  给定一些区间,然后求是否存在三个互不覆盖的区间...
  直接贪心,找出一个右边界最左的,和一个左边界最右的
  再找是否存在一个区间能与这两个区间互不交叉
  
  然而当我乐呵呵地开了int64之后发现MLE了...
  
  然后想了半天...除了多次reset之外根本找不到不存l,r的方法啊...
  那就存吧..发现官方题解上说用unsigned int,自然溢出真好啊!本来还担心10位乘10位int64也会乘爆
  然后发现Pas里面还真有一个这样神奇的东西叫做longword...
  乐呵呵地交了一发发现WA掉了...
  机智地放弃了Pas..我相信一定是longword的自然溢出出现了问题
  然后用C++写..就陷入了漫长的RE...
  最后发现是变量开在了int main()里面...
  唔...
 
 #include<cstdio>
#include<cstdlib>
#include<cstring>
const int maxn = ;
unsigned int l[maxn],r[maxn];
int main(){
int test;
scanf("%d",&test);
while (test--){
unsigned int n,a,b,c,d,tem;
scanf("%d%d%d%d%d%d%d",&n,&l[],&r[],&a,&b,&c,&d);
for (int i=;i<=n;i++) l[i]=l[i-]*a+b,r[i]=r[i-]*c+d;
for (int i=;i<=n;i++) if (l[i]>r[i]){tem=l[i];l[i]=r[i];r[i]=tem;}
unsigned int x=r[],y=l[];
for (int i=;i<=n;i++){
if (r[i]<x) x = r[i];
if (l[i]>y) y = l[i];
}
int flag = ;
for (int i=;i<=n;i++) if (l[i]>x&&r[i]<y) flag = ;
if (flag) printf("YES\n");else printf("NO\n");
}
return ;
}
 
  晚安
 
  05/.May

[HDU5214]Movie解题报告|小水题大智慧的更多相关文章

  1. hdu5007 小水题

    题意:       给你一个串,如果出现子串 "Apple", "iPhone", "iPod", "iPad"输出MA ...

  2. hdu 4540 威威猫系列故事——打地鼠 dp小水题

    威威猫系列故事——打地鼠 Time Limit: 300/100 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total ...

  3. hdu 4524 郑厂长系列故事——逃离迷宫 小水题

    郑厂长系列故事——逃离迷宫 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) To ...

  4. POJ 1013 小水题 暴力模拟

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35774   Accepted: 11 ...

  5. Codeforces441A_Valera and Antique Items(水题)

    Valera and Antique Items time limit per test 1 second memory limit per test 256 megabytes input stan ...

  6. 2011 ACM-ICPC 成都赛区解题报告(转)

    2011 ACM-ICPC 成都赛区解题报告 首先对F题出了陈题表示万分抱歉,我们都没注意到在2009哈尔滨赛区曾出过一模一样的题.其他的话,这套题还是非常不错的,除C之外的9道题都有队伍AC,最终冠 ...

  7. Codeforces 524 解题报告

    打的很快乐的一次比赛hiahiahia, 才A掉4题rating就涨了100+ 距离比赛\(3\)天了, 由于博主实在太颓, 又补掉了\(E\)题, 到现在才发解题报告 A. 语法题, 读入输出就行了 ...

  8. LeetCode 2 Add Two Sum 解题报告

    LeetCode 2 Add Two Sum 解题报告 LeetCode第二题 Add Two Sum 首先我们看题目要求: You are given two linked lists repres ...

  9. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

随机推荐

  1. LintCode-4.丑数 II

    丑数 II 设计一个算法,找出只含素因子2,3,5 的第 n 大的数. 符合条件的数如:1, 2, 3, 4, 5, 6, 8, 9, 10, 12... 注意事项 我们可以认为1也是一个丑数 样例 ...

  2. <Android>spinner/AutoCompleteTextView绑定适配器

    position = (Spinner)findViewById(R.id.position); String[] str = {"CEO","CFO",&qu ...

  3. C#控件DropDownList下拉列表默认打开

    c#中的控件DropDownList要实现默打开确实不容易,之前也是想过页面上的点击之后就打开了,那直接模拟点击不就行了,试过后大失所望,根本没有效果. 于是网上找到了一个例子能实现IE浏览器下的打开 ...

  4. HDU 2148 Score

    http://acm.hdu.edu.cn/showproblem.php?pid=2148 Problem Description 转眼又到了一年的年末,Lele又一次迎来了期末考试.虽然说每年都要 ...

  5. .NET环境下,通过LINQ操作SQLite数据库

    //对应数据库中的某个表 [Table(Name = "main.Student")]    public class Student    {        [Column(Na ...

  6. python json 序列化

    如果我们要在不同的编程语言之间传递对象,就必须把对象序列化为标准格式,比如XML,但更好的方法是序列化为JSON,因为JSON表示出来就是一个字符串,可以被所有语言读取,也可以方便地存储到磁盘或者通过 ...

  7. tcp中的发送窗口是啥意思?

    初始的三次握手: 02:52:36.585412 IP 127.0.0.1.59764 > 127.0.0.1.8000: Flags [S], seq 3800457532, win 4369 ...

  8. PCA误差

    我们知道,PCA是用于对数据做降维的,我们一般用PCA把m维的数据降到k维(k < m). 那么问题来了,k取值多少才合适呢? PCA误差 PCA的原理是,为了将数据从n维降低到k维,需要找到k ...

  9. iOS图片上传后被旋转的问题

    最近用PHP做了一个图片合成程序,前端是通过HTML的file input选取自定图片,POST到php后台调整尺寸后与事先准备好的背景图进行合成. 通过测试发现,上传后的自定图片有的被旋转了,有的是 ...

  10. POJ.1006 Biorhythms (拓展欧几里得+中国剩余定理)

    POJ.1006 Biorhythms (拓展欧几里得+中国剩余定理) 题意分析 不妨设日期为x,根据题意可以列出日期上的方程: 化简可得: 根据中国剩余定理求解即可. 代码总览 #include & ...