题目链接:HDU 5172 GTY's gay friends
题意:给出一串序列,询问[l,r]区间里是否存在1~l-r+1的一个排列。
思路:1~l-r+1的一个排列 等价于 [l,r]中元素互不相同且[l,r]区间和等于(1+len)*len/2(len=l-r+1)。
区间和可以用前缀和来处理。
元素互不相同,记录位置i上a[i]上次出现的位置记做pre[i],再用线段树来维护区间...
分类:
其他好文 时间:
2015-02-10 16:50:48
阅读次数:
186
题意:判断两点是否在线段的同一方,点不能在线上。题解:模拟一下DescriptionA determined army on a certain border decided to enumerate the coordinates in its patrol in a way to make it...
分类:
其他好文 时间:
2015-02-09 22:51:17
阅读次数:
112
题意:一段数字,逆置其中两个使其递增DescriptionBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of ndisti...
分类:
其他好文 时间:
2015-02-09 10:54:29
阅读次数:
160
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 expr...
分类:
其他好文 时间:
2015-02-08 18:14:38
阅读次数:
114
传送门GTY's gay friendsTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 264Accepted Submission(s): 57P...
分类:
其他好文 时间:
2015-02-08 18:00:14
阅读次数:
199
#include#include#include#includeusingnamespacestd;constintMAX=100000+10;intres[MAX>1;build(L,mid,o=R){returnres[o];}intmid=(L+R)>>1;inttt=0;if(lsmid)t...
分类:
其他好文 时间:
2015-02-08 10:14:47
阅读次数:
146
题目大意:可以到相应的场次查看中文翻译。
思路:其实这道题很简单,对于一个等差数列,我们要判断他是否每个数都出现,只需要判断区间和或者是最大值是否符合即可,但这边需要注意的便是中间的重复部分。最大值的判重必要性我就不知道了,而且我也不会做,目测做也超时。
这边就写一下偷别人的区间和 随机数判重的做法
其实这边判重的方法是给一个数加上一个超过1000007的权,然后在计算和的时候,便是唯一的。...
分类:
其他好文 时间:
2015-02-07 23:05:39
阅读次数:
196
uva 11218 KTV
One song is extremely popular recently, so you and your friends decided to sing it in KTV. The song has 3 characters, so exactly 3 people should sing together each time (yes, ther...
分类:
其他好文 时间:
2015-02-05 18:35:13
阅读次数:
171
POJ 2289 :
Description
Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long th...
分类:
其他好文 时间:
2015-02-05 15:01:49
阅读次数:
166
英文博客地址:http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-viii-followers-contacts-and-friends中文翻译地址:http://www.pythondoc.com/flask-mega-...
分类:
其他好文 时间:
2015-02-05 12:56:37
阅读次数:
332