This is the mayor's election. Then everyone can post billboards. We can cover the remaining billboards of others.
After thinking about this question for more than two hours, I finally couldn't help reading the question. Only simple hash and line segment tree update are found
Because there are 10000 individual campaigns, the maximum number is 10000. 20000 points, the line segment tree will not burst into memory;
There are two specific operations:
(1) After hashing, each interval endpoint is regarded as the underlying node, and as long as it is colored, It is the full Dyeing of the two nodes.
(2) simple line segment tree update
For details, see the code:
# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; # define Maxx 20010 # define lson l, m, RT <1 # define rson m + 1, R, RT <1 | 1int sum [Maxx <2]; // set int num [Maxx <1]; int CNT; int hash [Maxx <1]; int A [Maxx], B [Maxx]; void pushup (INT RT) // update the node, pass the color of the node, and the node can be initialized, indicating that there are more than one poster on the node.
{If (sum [RT]! =-1) {sum [RT <1] = sum [RT <1 | 1] = sum [RT]; sum [RT] =-1 ;}} void Update (int l, int R, int C, int L, int R, int RT) {If (L <= L & R> = r) {sum [RT] = C; return;} pushup (RT); int M = (L + r)> 1; if (L <= m) Update (L, r, C, lson); If (r> m) Update (L, R, C, rson);} void query (int l, int R, int RT) {If (sum [RT]! =-1) // not only one poster is displayed
{If (! Hash [sum [RT]) CNT ++; hash [sum [RT] = 1; return;} If (L = r) return; int M = (L + r)> 1; query (lson); query (rson);} int cheak (int aa, int NN, int num []) // determine the point over there
{ int l=0,r=nn-1; while(l<=r){ int m=(l+r)>>1; if(num[m]==aa) return m; if(num[m]<aa) l=m+1; else r=m; } return -1;}int main(){ int T,n; scanf("%d",&T); while(T--){ scanf("%d",&n); int m=0; for(int i=0;i<n;i++){ scanf("%d%d",&a[i],&b[i]); num[m++]=a[i]; num[m++]=b[i]; } sort(num,num+m); // for(int i=0;i<m;i++) // printf("%d %d\n",i,num[i]); int h=1; for(int i=1;i<m;i++){ if(num[i]!=num[i-1]) num[h++]=num[i]; } //puts("--------------"); // for(int i=0;i
Poj 2528 mayor's posters