题意:给一个序列这个序列都是由0和1组成,现在随意拿出来一个序列,然后说出他的和是奇数还是偶数,因为有可能存在假话,让你判断前多少条没有假话,也就是查找第一个假话的位置-1 ////////////////////////////////////////////////// 这道题很像D题,都是线段区间,不过数据比较大,需要离散化一下. #include <stdio.h> #include<algorithm> ; ;     }     ;         ];        …
Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) and ask him,…
Super Mario Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5101    Accepted Submission(s): 2339 Problem Description Mario is world-famous plumber. His “burly” figure and amazing jumping abilit…
题目链接:https://vjudge.net/problem/POJ-1177 A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the oth…
题目链接:https://vjudge.net/problem/HDU-1542 There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, these maps describe different reg…
(题外话:这题这是ACMer的福利啊……)我非常不擅长做矩形类的数据结构一般来说,二维的问题我们要转化为一维来考虑感觉一般的手法是对一维排序,并且线性扫描这一维,然后用各种数据结构维护另一维上的最优值这道题我们首先对x排序,然后扫描x坐标这时候我们要维护2条扫描线,一左一右(应该就是two pointer)扫描线之间的长度就是要求小于等于窗口宽度随着右扫描线的移动,我们把这条扫描线上的点加到某个数据结构中随着左扫描线的移动,我们把这条扫描线的点删除显然每个点添加一次且删除一次,要做O(n)次操作…
算法 线段树 + 离散化 思路 对\((x,y,h)\)的左右端点\(x,y\)进行离散化,离散化前的原值记为\(val[i]\),对每个矩形按高度\(h\)从小到大排序. 设离散化后的端点有\(M\)个,则对如图所示\(M-1\)个规则矩形编号为\([1,M-1]\),可以由\(h_{[i, i+1]}\times(val[i+1] - val[i])\)得出第\(i\)个矩形的面积. 开一颗区间为\([1,M-1]\)的线段树,按\(h\)从小到大依次对线段树区间覆盖,可以保证高的矩形覆盖了…
题意:给一个长度为n的序列a.1≤a[i]≤n.m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2.如果存在,输出这个数,否则输出0. n,m≤500000 思路:这题可以用主席树巧妙地做 询问(x,y)区间时直接输出a[query(x,y)] 首先区间内个数>(r-l+1)/2的数字如果有的话有且只有一个 其次答案数字肯定在数字总和大于一半的一边 这样询问可以做到logn 离散化注意 ..]of record l,r,s:longint; end…
Parity Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12853   Accepted: 4957 题目链接:http://poj.org/problem?id=1733 Description: Now and then you play the following game with your friend. Your friend writes down a sequence consisting…
传送门 题意:有一个长度已知的01串,给出[l,r]这个区间中的1是奇数个还是偶数个,给出一系列语句问前几个是正确的 思路:如果我们知道[1,2][3,4][5,6]区间的信息,我们可以求出[1,6]的信息 可以将将闭区间[x,y]转换成(x - 1,y]左开右闭区间 那么我们可以用并查集来做,每次输入两个数 x 和 y 判断两者是否在同一并查集中,如果在,那么可以直接判断奇偶 如果两者不在同一并查集中将两者合并,并求出两者的根之间的距离 距离可在 find 函数中维护 注意:数据范围比较大,需…