题意:
一块矩形空间 一开始每个格子都是1 有4种操作: S操作将(x1,y1)-(x2,y2)所画出的矩形中的数求和 A操作是在(x,y)加z D是在(x,y)减z 注意不能减成负数 M是移动
思路:
裸二维树状数组… POJ上有楼教主出过的题
代码:
#include
#include
#include
using namespace std;
#defi...
分类:
其他好文 时间:
2014-07-15 12:32:01
阅读次数:
279
题意:
n只虫子 m种交配方式 并给出m对交配 问 是否存在基… 0.0
思路:
简单的带权并查集 比POJ上那道食物链基础 而且用二分染色可以水过(由于性别只有两种…)
带权并查集可以利用权值维护不同集合间的“关系”
代码书写时注意getf函数中利用fa[x]更新x和根的关系 merge时注意fy权值利用x、y的权值的计算方法
代码:
#include...
分类:
其他好文 时间:
2014-07-15 12:30:45
阅读次数:
234
This is really classic searching problem to solve. The key is pruning.(My reference:http://blog.csdn.net/lyy289065406/article/details/6647960)There ar...
分类:
其他好文 时间:
2014-07-15 10:04:36
阅读次数:
221
这一题主要用到了BFS广度优先算法 若马的当前位置为(x,y),那么下一步就有8种可能。(x+2 , y+1) , (x+1 , y+2 ) , (x-1 , y+2) , (x-2 , y+1)(x+2 , y -1) , (x+1 , y-2 ) , (x-1 , y-2) , (x-2 , y...
分类:
其他好文 时间:
2014-07-14 20:17:45
阅读次数:
296
Tautology
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 9302
Accepted: 3549
Description
WFF 'N PROOF is a logic game played with dice. Each die has six...
分类:
其他好文 时间:
2014-07-14 18:45:09
阅读次数:
289
The Suspects
Time Limit: 1000MS
Memory Limit: 20000K
Total Submissions: 21427
Accepted: 10375
Description
Severe acute respiratory syndrome (SARS), an atypical ...
分类:
其他好文 时间:
2014-07-14 18:37:20
阅读次数:
232
一道比最基础的并查集有优化的题;
l 并查集的优化
1、Find_Set(x)时 路径压缩
寻找祖先时我们一般采用递归查找,但是当元素很多亦或是整棵树变为一条链时,每次Find_Set(x)都是O(n)的复杂度,有没有办法减小这个复杂度呢?
答案是肯定的,这就是路径压缩,即当我们经过"递推"找到祖先节点后,"回溯"的时候顺便将它的子孙节点都直接指向祖先,这样以后...
分类:
其他好文 时间:
2014-07-14 18:30:13
阅读次数:
233
Ubiquitous Religions
Time Limit: 5000MS
Memory Limit: 65536K
Total Submissions: 23093
Accepted: 11379
Description
There are so many different religions in the world...
分类:
其他好文 时间:
2014-07-14 18:28:12
阅读次数:
222
POJ 2524 Ubiquitous Religions (幷查集)...
分类:
其他好文 时间:
2014-07-14 18:23:10
阅读次数:
291
Parencodings
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 19352
Accepted: 11675
Description
Let S = s1 s2...s2n be a well-formed string of parentheses...
分类:
其他好文 时间:
2014-07-14 18:19:13
阅读次数:
271