上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 28 下一页
摘要: 各种操作o(╯□╰)o...不过都挺简单,不需要lazy标记。方法1:块状链表块状链表太强大了,区间操作实现起来简单暴力,效率比splay稍微慢一点,内存开销小很多。 1 #include 2 #include 3 #include 4 using namespace std; 5 ... 阅读全文
posted @ 2015-08-17 14:23 hxy_has_been_used 阅读(415) 评论(0) 推荐(1) 编辑
摘要: 这个题是真正可以体现出块状链表的优点。数组定位快但是插入慢,而链表插入快却定位慢。块状链表正是结合了数组和链表的优点将定位和插入的复杂度变成了sqrt(n)。块状链表: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 c... 阅读全文
posted @ 2015-08-16 15:35 hxy_has_been_used 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 二进制真的是个神奇的东西!类似floyd求传递闭包,这里g[i][j]表示i点到j点的状态(即符合条件的公司的集合)。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 201; 7 const... 阅读全文
posted @ 2015-08-16 13:31 hxy_has_been_used 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 很容易想到要用容斥原理,这里有一个小技巧就是用二进制数来表示集合的交。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 typedef long long ll; 7 const int MOD = 1000007; 8... 阅读全文
posted @ 2015-08-16 10:11 hxy_has_been_used 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 枚举每个点是必须的,问题就在于如何快速求出曼哈顿距离之和。可以将x坐标和y坐标分别排序,枚举到点(xx,yy)的时候在排好序的x和y数组中二分找到其位置,然后之前的数字都小于,之后的数字都大于,就可以去掉绝对值了。 1 #include 2 #include 3 #include 4 #inc... 阅读全文
posted @ 2015-08-16 08:54 hxy_has_been_used 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 因为数据量非常小(n 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 10; 8 int dp[N]; 9 int n, ans;10 11 struct T12 {13 int a,... 阅读全文
posted @ 2015-08-15 18:55 hxy_has_been_used 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 容易联想到尺取法,因为假设从第s页开始阅读至少需要读到t页才能覆盖所有知识点的话,那么如果从s+1页开始阅读,至少要读到t'>=t的位置。于是可以考虑用map维护一下。 1 #include 2 #include 3 #include 4 #include 5 using namespace... 阅读全文
posted @ 2015-08-15 09:47 hxy_has_been_used 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 因为斐波那契数列增长很快(指数级),所以10Y以内只有不到50个斐波那契数,将这些数字所有可能的乘积存起来查询即可,这里采用bfs+set的方式。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespac... 阅读全文
posted @ 2015-08-15 09:02 hxy_has_been_used 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 整数拆分问题:给定一个正整数n,将n拆分为若干数字的和,问有多少种方法?此题为整数拆分问题的子问题,拆分出的数字要求是2的幂次。定义dp[i][k]表示枚举到第k个数字时数字i的拆分方案数。则有状态转移方程: dp[i][k] = dp[i][k - 1] + dp[i - num[k]][k];... 阅读全文
posted @ 2015-08-14 19:27 hxy_has_been_used 阅读(442) 评论(0) 推荐(0) 编辑
摘要: 比较简单的sg函数的应用,将每一堆的sg值求出,则总游戏的sg值为3个异或起来。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 1001; 7 const int M = 20; 8 int... 阅读全文
posted @ 2015-08-14 16:16 hxy_has_been_used 阅读(162) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 28 下一页