摘要: 这个题是真正可以体现出块状链表的优点。数组定位快但是插入慢,而链表插入快却定位慢。块状链表正是结合了数组和链表的优点将定位和插入的复杂度变成了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) 编辑