随笔分类 -  ACM 枚举

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2807题意 : 类似于最短路,不过几个city之间的联系是从他们的矩阵信息中所得到的。(矩阵A * 矩阵B = 矩阵C 则说明A 于 C 之间单向连通并且距离为1,PS : 但是并不是说明B可以连通C,因为矩阵乘法位置互换之后结果不一定相等)思路 :矩阵乘法复杂度在O(M^3),而枚举每一组A,B,C复杂度又是O(N^3),一开始傻傻的去试了下,果断TLE。好吧,后来把 A * B的结果保存在新的矩阵里,再去寻找是否存在C,使得复杂度大约降到了O(M ^ 3 * N ^ 2),1900MS险过~~~~囧。PS 阅读全文
posted @ 2013-08-08 09:33 cnwsycf 阅读(156) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1575题意 : 裸裸的矩阵相乘思路 : 因为K比较大,所以我使用二进制优化,最后只要把主对角线上的数字加起来最后取下模即可。//Danceonly #include #include #include #include #include using namespace std; typedef long long LL; const double INF = 100000007; const double eps = 1e-9; const int maxn = 15; const int ... 阅读全文
posted @ 2013-08-07 16:07 cnwsycf 阅读(148) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2157题意 : 中文的、就不多说了~~~~废话 :嗯,第一次使用矩阵这一看似很高端的东东~~,表示大一上学期的时候实在是水水地听线性代数的,现在才发现矩阵真的蛮重要的(默默的鄙视下线代老师——从来都没和我们说过矩阵的用处)。这道题目使用矩阵,我是开三维数组的,保存每个状态,状态P(n) = P(n-1) * p(0)。然后Q次就直接虐好了,最后只要注意下 K == 0 的情况即可。//Danceonly #include #include #include #include #include u... 阅读全文
posted @ 2013-08-07 16:04 cnwsycf 阅读(257) 评论(0) 推荐(0)
摘要:DescriptionThe factory cuts rectangular M × N granite plates into pieces using a special machine that is able to perform cuts in 4 different directions: vertically, horizontally, and diagonally at the angle of 45 degrees to the sides of the plate. Every cut is a straight line that starts and en 阅读全文
posted @ 2013-07-03 09:58 cnwsycf 阅读(191) 评论(0) 推荐(0)