ZOJ 3953 Intervals】的更多相关文章

题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3953 题意 给出N个区间,求去掉某些区间,使得剩下的区间中,任何的三个区间都不两两相交. 思路 将所有区间 以左端点为键值从小到大排序 然后三个三个一组 进行判断 如果 这三个中有两两相交的 那么就删去右端点最大的 因为这个区间对答案的贡献最小 然后三个区间当中没有两两相交的,那么下一次进来的区间就替换掉右端点最小的. AC代码 #include <cstdio…
线段树,排序. 按照$R$从小到大排序之后逐个检查,如果$L$,$R$最大值不超过$2$,那么就把这个区间放进去,区间$+1$,否则不能放进去. #include<bits/stdc++.h> using namespace std; int T,n,sz; ]; ]; ],m[]; int P; bool cmp(X a,X b) { return a.R<b.R; } int get(int x) { ,rr=sz,res; while(ll<=rr) { ; ; else i…
Chiaki has n intervals and the i-th of them is [li, ri]. She wants to delete some intervals so that there does not exist three intervals a, b and c such that aintersects with b, b intersects with c and c intersects with a. Chiaki is interested in the…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5572 题意:给出n个线段,问最少删除几个线段可以使得任意一个点不会被三个以上的线段覆盖. 思路:首先离散化坐标. 然后想着按右端点从小到大排序后直接O(n)扫的贪心,但是后面发现错误了. 应该按左端点从小到大排序,然后用一个优先队列(按右端点从大到小排序). 开始扫坐标,当有与该坐标相同的点的左端点就进队,用ed[]记录右端点的位置. 用cnt记录当前这个点有多少个区间覆盖,…
题目链接: POJ:http://poj.org/problem?id=1201 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1384 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=508 Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5572 Intervals Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge Chiaki has n intervals and the i-th of them is [li, ri]. She wants to delete some intervals so that there do…
Intervals Time Limit: 10 Seconds      Memory Limit: 32768 KB You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: > reads the number of intervals, their endpoints and integers c1, ..., cn from the stand…
  // 思路 : // 图建好后 剩下的就和上一篇的 火烧连营那题一样了 求得解都是一样的 // 所以稍微改了就过了 // 最下面还有更快的算法 速度是这个算法的2倍#include <iostream> #include <map> #include <algorithm> #include <queue> #include <math.h> #include <stdio.h> #include <string.h>…
Intervals Time Limit: 1 Second      Memory Limit:65536 KB      Special Judge Chiaki has n intervals and thei-th of them is [li,ri]. She wants to delete some intervals so that there does not exist three intervalsa,b andc such thata intersects withb,b…
差分约束系统. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<algorithm> using namespace std; ; map<int, int> jz[maxn]; vector<int>ljb[maxn]; int di…