摘要: 思路:1741的A1送 1.#include#include#include#include#include#define Maxn 40010#define Maxm 80010#define inf 0x7fffffffusing namespace std;int head[Maxn],vi[Maxn],e,ans,num,k,n,m;int mx[Maxn],mi,dis[Maxn],root,size[Maxn];struct Edge{ int u,v,val,next;}edge[Maxm];void init(){ memset(vi,0,sizeof(vi)); ... 阅读全文
posted @ 2013-08-14 20:55 fangguo 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 思路:这题我是看 漆子超《分治算法在树的路径问题中的应用》写的。附代码:#include#include#include#include#include#define Maxn 10010#define Maxm 20010#define inf 0x7fffffffusing namespace std;int head[Maxn],vi[Maxn],e,ans,num,k,n;int mx[Maxn],mi,dis[Maxn],root,size[Maxn];struct Edge{ int u,v,val,next;}edge[Maxm];void init(){ memse... 阅读全文
posted @ 2013-08-14 20:44 fangguo 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 思路:主要就是一个动态方程dp[now][(j*Exp[len[num[i]]]+num[i])%k]+=dp[pre][j];我用的是滚动数组。其实也就是dp[i][(j*Exp[len[num[i]]]+num[i])%k]+=dp[i-1][j];唯一需要注意的就是存在长度长于n的串,要减掉。#include#include#include#include#define Maxn 100010using namespace std;int len[Maxn],Exp[Maxn*3],n,k,num[Maxn];int dp[3][210];void init(){ int i; ... 阅读全文
posted @ 2013-08-14 18:17 fangguo 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 思路:这题我是看了题目后,上百度搜了一下才知道还有求最大曼哈顿距离的方法。直接把代码copy过来,研读一下,知道了代码实现机制,自然就很容易想到用优先队列来维护每种状态下的xi,yi之和的最大值最小值,以及其属于哪个点。那么对于删点操作只需要标记为不存在就可以了。在队列出队时,若队顶元素不存在,就出队。#include #include #include #include #include #include #include #include using namespace std;const int Maxn=100005;const int inf=0x7fffffff;struct Qu 阅读全文
posted @ 2013-08-14 15:09 fangguo 阅读(801) 评论(0) 推荐(0) 编辑
摘要: 题意:每个用户对数据库的查询请求都会首先用该数据库的服务器序列的第一个去执行任务,若第一个坏了,就由第二个执行。最多只会坏一个服务器。要求是考虑最多坏一个的情况下,所有服务器中执行用户查询的数目最大值与最小值之差不能超过1。思路:对于n>=m的情况,很容易能解决掉,关键是n#include#include#include#includeusing namespace std;int ans[110][3],pre[110],vi[110],num[110],n,m;struct Que{ int val,c; int operator temp.c; }};int Ok(){... 阅读全文
posted @ 2013-08-14 15:03 fangguo 阅读(256) 评论(0) 推荐(0) 编辑