2012年7月16日
摘要:
http://poj.org/problem?id=2492和poj 1703 一样不再多说代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algorithm>#include<set>using namespace std;const int N=100010;int f[N];int same[N];int findf(int 阅读全文
posted @ 2012-07-16 20:29
夜->
阅读(159)
评论(0)
推荐(0)
摘要:
http://poj.org/problem?id=1703题目大意:有一些罪犯,分两伙 每伙至少一个两种操作D a b:a和b不是一伙的A a b:a和b 之间的关系是什么思路:并查集,先把可以确定关系的罪犯放在一个集里 再多一个数组表示此节点和他指向的上一个节点是否一样(是否同伙)代码及其注释:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algor 阅读全文
posted @ 2012-07-16 20:02
夜->
阅读(170)
评论(0)
推荐(0)
摘要:
http://poj.org/problem?id=3264RMQ 模板题参考资料:http://wenku.baidu.com/view/53e2b6ed4afe04a1b071deb5.html代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<algorithm>#include<stack>using namespace std 阅读全文
posted @ 2012-07-16 09:56
夜->
阅读(194)
评论(0)
推荐(0)
摘要:
http://poj.org/problem?id=3321题目大意:给你N个点组成的树 每个点初始化为1 有两种操作C x:改变点的值 是1变0 是0变1Q x:问以x为根的子树上点值的和思路:主要是把树映射到树状数组中一遍dfs把点重新编号 low和high low表示刚搜到此点时的计数,high是搜玩其子树内所有节点后回来的计数编号比如说又n个点那么根节点1的low=1,high=2*n这样就映射到树状数组中啦。代码及其注释:#include<iostream>#include<cstdio>#include<cstring>#include<s 阅读全文
posted @ 2012-07-16 08:44
夜->
阅读(181)
评论(0)
推荐(0)
浙公网安备 33010602011771号