上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 28 下一页
摘要: 差分约束第一题,想明白以后就可以建图了。由于此题数据特殊,队列优化的spfa会超时,可以改成用栈来优化。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int INF = 99999... 阅读全文
posted @ 2015-08-28 13:59 hxy_has_been_used 阅读(123) 评论(0) 推荐(0)
摘要: “反转类问题”需要注意的是pushdown懒标记的时候要用异或(或者++%2)而不是赋值,因为它是和奇偶性有关系的。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100001;... 阅读全文
posted @ 2015-08-28 09:57 hxy_has_been_used 阅读(113) 评论(0) 推荐(0)
摘要: n participants of «crazy tea party» sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes... 阅读全文
posted @ 2015-08-27 20:31 hxy_has_been_used 阅读(137) 评论(0) 推荐(0)
摘要: 倒着考虑,如果最后一只牛的前面有x只比它小,那么它就是第x+1只牛,从序列中去掉它。对倒数第二只牛来说也同理。可以用树状数组来维护前缀和,一开始每个位置都是1,求出结果的牛从树状数组中删掉(update成0),即可获得答案。 1 #include 2 #include 3 #include 4... 阅读全文
posted @ 2015-08-27 20:00 hxy_has_been_used 阅读(113) 评论(0) 推荐(0)
摘要: 很容易想到插板法的模型,即:n个没有区别的小球放到m个不同的盒子里(允许某些盒子为空)的方法数c[n + m - 1][m - 1]。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int MOD = 10... 阅读全文
posted @ 2015-08-27 10:21 hxy_has_been_used 阅读(118) 评论(0) 推荐(0)
摘要: 想到分解质因数的话就很简单了,注意此题要求幂次至少为1,所以幂次为0即为Impossible to divide。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 10... 阅读全文
posted @ 2015-08-27 10:06 hxy_has_been_used 阅读(232) 评论(0) 推荐(0)
摘要: 维修数列的简化版,要求的操作还是挺多的,运行时间大概1s。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100002; 7 int v[N]; 8 int n, m; 9... 阅读全文
posted @ 2015-08-26 15:26 hxy_has_been_used 阅读(244) 评论(0) 推荐(0)
摘要: 切割的话就split再merge,区间修改就splay然后lazy标记。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 300000; 7 int ans[N]; 8 int... 阅读全文
posted @ 2015-08-25 09:35 hxy_has_been_used 阅读(138) 评论(0) 推荐(0)
摘要: splay第一题,有了Treap的基础以后感觉splay还是比较好理解的,splay的优势在于编程复杂度比较低且效率不错,通过splay操作以及衍生的split和merge操作可以实现很强大的功能。 1 #include 2 #include 3 #include 4 using na... 阅读全文
posted @ 2015-08-24 20:18 hxy_has_been_used 阅读(161) 评论(0) 推荐(0)
摘要: 理解清楚题意以后就明白为什么要用并查集了。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100001; 7 int f[N]; 8 int ans; 9 10 void init()11 ... 阅读全文
posted @ 2015-08-24 10:31 hxy_has_been_used 阅读(211) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 28 下一页