HDU 5214 - Movie (贪心)
来源:互联网 发布:linux命令行下载mysql 编辑:程序博客网 时间:2024/05/16 01:22
题意
选出三个不重叠区间。
思路
考虑贪心。
进行三次扫描。每次都选取(左端点比上个右端点大)的点之中的最小右端点。
因为右端点的扩大必然导致下一个区间选取范围的缩小,所以这么做是最优的。
代码
#include <stack>#include <cstdio>#include <list>#include <cassert>#include <set>#include <fstream>#include <iostream>#include <string>#include <vector>#include <queue>#include <functional>#include <cstring>#include <algorithm>#include <cctype>#include <string>#include <map>#include <cmath>#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/hash_policy.hpp>using namespace std;#define LL long long#define ULL unsigned long long#define SZ(x) (int)x.size()#define Lowbit(x) ((x) & (-x))#define MP(a, b) make_pair(a, b)#define MS(arr, num) memset(arr, num, sizeof(arr))#define PB push_back#define X first#define Y second#define ROP freopen("input.txt", "r", stdin);#define MID(a, b) (a + ((b - a) >> 1))#define LC rt << 1, l, mid#define RC rt << 1|1, mid + 1, r#define LRT rt << 1#define RRT rt << 1|1#define FOR(i, a, b) for (int i=(a); (i) < (b); (i)++)const double PI = acos(-1.0);const int INF = 0x3f3f3f3f;const double eps = 1e-8;const int MAXN = 1e7+10;const int MOD = 1e9;const int dir[][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };const int seed = 131;int cases = 0;typedef pair<int, int> pii;pair<unsigned int, unsigned int> p[MAXN];int main(){ //ROP; int T; scanf("%d", &T); while (T--) { int n; unsigned int L1, R1, a, b, c, d; cin >> n >> p[1].X >> p[1].Y >> a >> b >> c >> d; for (int i = 2; i <= n; i++) { p[i].X = p[i-1].X*a+b; p[i].Y = p[i-1].Y*c+d; } for (int i = 1; i <= n; i++) if (p[i].Y < p[i].X) swap(p[i].Y, p[i].X); LL last_right = 0; bool flag = false; FOR(k, 0, 3) { ULL curAns = 0-1; for (int i = 1; i <= n; i++) { if ((LL)p[i].X <= last_right) continue; curAns = min(curAns, (ULL)p[i].Y); } if (curAns == 0ull-1) { flag = true; break; } last_right = curAns; } puts(flag ? "NO" : "YES"); } return 0;}
0 0
- HDU 5214 - Movie (贪心)
- hdu 5214 Movie(贪心)
- hdu 5214 Movie
- HDU 5214 MOVIE
- HDU 5214 Movie
- HDU 5214 Movie
- HDU ACM 5214 Movie ->贪心+自然溢出取模->水题里的学问
- 赛码1001 Movie(hdu 5214)
- HDU 5214 MOVIE(灵活题)
- HDU 3496 - Watch The Movie
- HDU 3496 Watch The Movie
- Hdu 3496 Watch The Movie
- hdu 3496 Watch The Movie
- hdu 3496 Watch The Movie
- hdu 3496 Watch The Movie
- HDU 3496 Watch The Movie
- hdu 3496 Watch The Movie
- HDU--3496 Watch The Movie
- 我读过的专业书(持续更新、排名不分先后)
- POJ 3616Milking Time 排序Dp
- Android LayoutInflater深度解析
- 移动端日期控件
- Java提高 - 八大排序方法之快速排序
- HDU 5214 - Movie (贪心)
- 一些shell脚本中,为什么要用 x""==x"abc"的格式进行字符串比较
- 联想台式机扬天系列设置双屏显示
- 关于VisualStudio性能分析数据中的独占样本数和非独占样本数的意义
- Swift中利用AppDelegate实现调用指定ViewController中的函数
- UVALive - 4253 Archery 暴力
- Remove Linked List Elements
- #import 指令
- .html和.jsp