GTY's gay friendsTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 【Problem Description】GTY has n gay friends. To manage...
分类:
其他好文 时间:
2015-02-16 18:06:23
阅读次数:
250
http://acm.split.hdu.edu.cn/showproblem.php?pid=5172官方题解
一个区间是排列只需要区间和为len(len+1)2(len为区间长度),且互不相同,对于第一个问题我们用前缀和解决,对于第二个问题,预处理每个数的上次出现位置,记它为pre,互不相同即区间中pre的最大值小于左端点,使用线段树或Sparse Table即可在O(n)/O(nlogn)的...
分类:
其他好文 时间:
2015-02-15 18:12:15
阅读次数:
161
字符串分隔:var str_componets = "I would prefer a face-to-face talk with my friends"str_componets.componentsSeparatedByCharactersInSet(NSCharacterSet(charac...
分类:
编程语言 时间:
2015-02-15 12:03:12
阅读次数:
171
Problem Description
GTY has n gay friends. To manage them conveniently, every morning he ordered all his gay friends to stand in a line. Every gay friend has a characteristic value ai , to express how...
分类:
其他好文 时间:
2015-02-14 13:47:38
阅读次数:
246
Problem Description
FFZ’s birthday is coming. GTY wants to give a gift to ZZF. He asked his gay friends what he should give to ZZF. One of them said, ‘Nothing is more interesting than a number multise...
分类:
其他好文 时间:
2015-02-14 12:20:03
阅读次数:
160
hdu 5172 GTY's gay friends
题意:
给出n个数, a[1],a[2],...a[n], m个询问, 对于每个询问[l,r], 问a[l],a[l+1],...,a[r]是不是集合{1,2,...,r-l+1}
限制:
1
思路:
预处理出,对于每个位置,它前一个相同的数对的位置。
如:
给出的数组: 1 2 1 2 3
预处...
分类:
其他好文 时间:
2015-02-13 18:38:41
阅读次数:
200
题目地址:HDU 5172
比赛的时候用一个维护了区间和,区间积,区间最值的线段树水过去了。。赛后数据改回10^6后,就TLE了。。
正解是区间和用前缀和维护就可以。然后维护一个该位上的数上一个出现额位置,那么每次查询,如果每个数的上一个出现的位置都小于l的话,那么就说明没有重复的,如果区间和符合全排列的和,那么就说明肯定是一个全排列了。
代码如下:
#include
#include ...
分类:
其他好文 时间:
2015-02-11 16:37:51
阅读次数:
150
DominationTime Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. Wha...
分类:
其他好文 时间:
2015-02-10 23:13:32
阅读次数:
267