http://poj.org/problem?id=2528
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 29016 | Accepted: 8405 |
Description
- Every candidate can place exactly one poster on the wall.
- All posters are of the same height equal to the height of the wall; the width of a poster can be any integer number of bytes (byte is the unit of length in Bytetown).
- The wall is divided into segments and the width of each segment is one byte.
- Each poster must completely cover a contiguous number of wall segments.
They have built a wall 10000000 bytes long (such that there is enough place for all candidates). When the electoral campaign was restarted, the candidates were placing their posters on the wall and their posters differed widely in width. Moreover, the candidates started placing their posters on wall segments already occupied by other posters. Everyone in Bytetown was curious whose posters will be visible (entirely or in part) on the last day before elections.
Your task is to find the number of visible posters when all the posters are placed given the information about posters' size, their place and order of placement on the electoral wall.
Input
Output
The picture below illustrates the case of the sample input.
Sample Input
1 5 1 4 2 6 8 10 3 4 7 10
Sample Output
4
Source
给你一个区间,然后用n条线段去覆盖,问最后能看到多少条线段.
思路:
由于线段的范围太大,而n小得多,我们可以考虑将区间按照位置离散化.也就是原来的1 20 30 40变为1 2 3 4
然后没条线段染上一种颜色,最后看有多少种颜色就可以了。。
#include
#include
#include
#include
using namespace std;
const int maxn=20010;
struct Tree
{
}T[maxn*4];
struct segment
{
}a[maxn*2];
int x[maxn*2],visCol;
bool hasCol[maxn*2];
void build(int ld,int rd,int i)
{
}
void modify(int l,int r,int col,int i)
{
}
void query(int i)
{
}
int main()
{
}