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-172-删除元素

    172-删除元素 给定一个数组和一个值,在原地删除与值相同的数字,返回新数组的长度. 元素的顺序可以改变,并且对新的数组不会有影响. 样例 给出一个数组 [0,4,4,0,0,2,4,4],和值 4 ...

  2. perf打印调用栈的过程

    perf_prepare_sample-->perf_callchain-->get_perf_callchain 上面的调用栈会使用 perf_event_output--> 0x ...

  3. arp_annouce=2详解

    arp_annouce=0的时候 手册上说的是到底是是说当我这个包出去的时候询问arp地址, 当arp_announce=0的时候,是说使用数据包中的地址去进行arp的请求, 当arp_announc ...

  4. SpringBoot Web(SpringMVC)

    入门工程: package com.example.demo.controller; import com.example.demo.entity.User; import org.springfra ...

  5. 【bzoj5064】B-number 数位dp

    题目描述 B数的定义:能被13整除且本身包含字符串"13"的数. 例如:130和2613是B数,但是143和2639不是B数. 你的任务是计算1到n之间有多少个数是B数. 输入 输 ...

  6. URL 编码规则

    规则: 1.将空格转换为加号(+) 2.对0-9.a-z.A-Z之间的字符保持不变 3.对于所有其他的字符,用这个字符的当前当前字符集编码在内存中的十六进制格式表示,并在每一个字节前加上一个百分号(% ...

  7. bzoj3489: A simple rmq problem (主席树)

    //========================== 蒟蒻Macaulish:http://www.cnblogs.com/Macaulish/  转载要声明! //=============== ...

  8. BZOJ3894:文理分科——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=3894 文理分科是一件很纠结的事情!(虽然看到这个题目的人肯定都没有纠结过) 小P所在的班级要进行文理 ...

  9. CF17E:Palisection——题解

    https://vjudge.net/problem/CodeForces-17E http://codeforces.com/problemset/problem/17/E 题目大意:给一个长度为n ...

  10. push与createElement性能比较

    下面的实验是验证push()函数与CreateElement()函数在创建HTML元素的效率.可以看出,实用push()确实效率要比后者要高,不过究竟可以高出多少,还需要有专研精神的朋友去测试了,这里 ...