摘要: 题意:点数n(n #include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson og[N];int ans[N],tf[N],lf[N],vis[N];void init(){ for(int i=0; i=(q[k].b*bit+1)&&v=q[k].l&&v=l&&v<=r) ans-=unionone(lf,i,v); } } return an... 阅读全文
posted @ 2013-09-29 19:50 baoff 阅读(497) 评论(0) 推荐(0) 编辑
摘要: 题意:一串项链,每颗珠子上有一个数字,任选连续的一段,按顺时针顺序将它们的数字拼起来,若新的数字是k的倍数,则这个数字是一个wonderful value 。求有多少个wonderful value 。题解:由于K非常小,我们可以用dp[j][i]表示以第j个数结尾的所有数字中模k为i的方案为多少,那么计算dp[j+1][i]的时候乘上偏移值并加上j+1个珠子的值就行了。复杂度为nk。注意如果读入数就去模的话,要记下原来的数的长度,比如9 和123拼起来9要乘1000,如果123先取模的话可能就乘100或者10了。就是这里卡了两个多少时……//#pragma comment(linker, & 阅读全文
posted @ 2013-09-26 16:56 baoff 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题意:给n*m的地图,在地图的点上走,(n+1)*(m+1)个点,两种操作:往下走D和往右走R。现在要从左上角走到右下角,给定两个操作串,问包含这两个串的走法总共有多少种。做法:用这两个串构建自动机,然后只要在自动机上走n+m+1步就好了。就像一个递推,dp[x][y][i][cur]表示在i状态到达x,y坐标时走过的串的状态为cur时的总方案数//#pragma comment(linker, "/STACK:102400000")#include#include#include#include#include#include#include#include#includ 阅读全文
posted @ 2013-09-24 12:02 baoff 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 题意:n个点,m条边的无向图,每条边abc,点a到点b的权值是c。p(0#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o<<1,l,mid#define rson o<<1|1,mid+1,r#define lo o<<1#define ro o<<1|1#define ULL unsigned long long#define LL long lo 阅读全文
posted @ 2013-09-22 11:36 baoff 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目大意:判断一堆人能否分成两组,组内人都互相认识。思路:不认识的人一定不在一起!#include#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson og[N]; while(scanf("%d",&n)==1) { for(int i=0;i<=n;i++) { g[i].clear();//WA f[... 阅读全文
posted @ 2013-09-22 09:20 baoff 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 单调栈可以维护一个长度递增的序列,当新加入的元素不递增时,会把前面的元素截断,使其保持递增由于截断之后大量的元素长度相同,所以没有必要把所有所有元素压入栈,只需将这些元素压缩成一个(用矩阵块和表示!),记录个数,放入栈既可。//#pragma comment(linker, "/STACK:102400000")#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o= 阅读全文
posted @ 2013-09-19 21:42 baoff 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 题意,有一个n多边形,且是正多边形,从中任取3点构成一个三角形。告诉你这3个点的坐标,求满足条件的最小的n。基本思路:在n多边形外画一个圆找规律。暴力,从i(3#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o0?1:-1;}struct Point{ double x,y; int read() { return scanf("%lf%lf",&x,&y); . 阅读全文
posted @ 2013-09-19 17:37 baoff 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 题目大意:n个石头围成一圈,每个有权值,现在两只兔子从任意两个石头开始,一个顺时针,一个逆时针跳,可以跳任意远,但是不能超过一圈,要两只兔子所在的石头对应的权值任意时刻都相同,问兔子最多跳多少步。//#pragma comment(linker, "/STACK:16777216")#include#include#include#include#include#include#include#include#include#include#include#define tree int o,int l,int r#define lson o<<1,l,mid# 阅读全文
posted @ 2013-09-19 10:43 baoff 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 最短路问题,主要考的是构图的思想;思路:将每一层拆分成两个点,例如,第一层分成n+1即(n+2*i-1)和n+2(n+2*i);总共3*n个点;也就是第i层分成n+2*i-1和n+2*i;规定n+2*i-1始终作为入边,n+2*i始终作为出边;如果某个点属于第i层,就连边i->n+2*i-1,n+2*i->i,权值为0;然后根据题意,相邻的层次连边,权值为C,n+2*i-1->n+2*(i+1)和n+2*(i+1)-1->n+2*i;然后跟着输入的边构图;#include#include#include#include#include#include#include#i 阅读全文
posted @ 2013-09-13 17:14 baoff 阅读(296) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionYou are given a array with N nodes. The array nodes are numbered from 1 to N ( represented by a_i ). In the start, the colorof any node in the array is white or black. We define that the "distance" between a and b is min{a_i| a k,初始化时记下在i左侧最近的小于k的数字的位置L[i],同理R[i]。找到L[i]左 阅读全文
posted @ 2013-08-28 11:52 baoff 阅读(187) 评论(0) 推荐(0) 编辑