上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 28 下一页
摘要: 题意和方法都很简单,只是需要注意的地方很多,例如加边时起点终点可能在一个集合内,还有既冲突也不全的情况优先判断冲突。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const in... 阅读全文
posted @ 2015-08-05 17:05 hxy_has_been_used 阅读(551) 评论(0) 推荐(0) 编辑
摘要: 简单的拓扑排序,要求字典序最小的话用优先队列来维护入度为0的点即可。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 501; 8 const int M = 1000... 阅读全文
posted @ 2015-08-05 14:49 hxy_has_been_used 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 很显然,i和j不同时,A[i]+A[j]会被异或两次,也就是没有异或。所以只要把每个数的二倍异或一遍(或者异或一遍最后乘2)就可以得到答案。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 typedef long lo... 阅读全文
posted @ 2015-08-04 19:00 hxy_has_been_used 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 由于只删除最小值和只查询最大值,所以我们只要维护一个maxn和一个size即可,需要注意的是删除到集合空时需要重新将maxn赋值为无穷小。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main () 7 { ... 阅读全文
posted @ 2015-08-04 18:47 hxy_has_been_used 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 最基本的求割点的题目,建议深入理解该dfs的过程,还有就是对于同一个点来说,满足它是割点的条件可能会成立多次,所以一定要在dfs结束后统计割点个数,而不是在dfs的过程中实现。 1 #include 2 #include 3 #include 4 using namespace std; 5 ... 阅读全文
posted @ 2015-08-04 09:57 hxy_has_been_used 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 只有20个点,从大到小排序然后枚举即可。这里做了一个优化,不模大于自己的数,因为这是徒劳的,我们要求的是最小的r。注意:不排序就枚举是错误的,想一想,为什么。 1 #include 2 #include 3 #include 4 #include 5 using namespace std;... 阅读全文
posted @ 2015-08-03 18:49 hxy_has_been_used 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 理清逻辑关系即可。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 1000; 8 const int M = 5000000; 9 int head... 阅读全文
posted @ 2015-08-03 17:09 hxy_has_been_used 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题意有点模糊,其实是这样的:对于每一个队伍,队长和其余两人(视为整体)至少留下一个,且不能同时留下;对于每一对队员,A留下则B不能留下,B留下则A不能留下。建图求解即可,不过还是想吐槽一下出题人的中文,o(╯□╰)o,请叫我建边小王子。 1 #include 2 #include 3 #i... 阅读全文
posted @ 2015-08-03 16:27 hxy_has_been_used 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 继续测模板... 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct Node 9 { 10 Node * ch[2]; 11 ... 阅读全文
posted @ 2015-08-02 16:13 hxy_has_been_used 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 又一道数据结构的题目,用Treap可以轻松解决。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct Node 9 { 10 Node... 阅读全文
posted @ 2015-08-02 15:43 hxy_has_been_used 阅读(164) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 28 下一页