摘要: #include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;const int inf = 0x3f3f3f3f;const int N = 101;int n, m; struct Matrix{ int mat[N][N]; Matrix(){ memset(mat,0,sizeof(mat)); } void input(){ for(int i = 0; i < m; i++) for(i... 阅读全文
posted @ 2013-04-22 22:48 yefeng1627 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题意: 有N个顶点,每个顶点由M*M矩阵构成, 对于顶点 A, B,C, 若 A*B = C,则存在一条路 (a,c)路径为1, K次询问,问 (x,y)最短路径。 N,M 《= 100解法: 用矩阵乘法 暴力找出 顶点间关系, 然后Floyd跑一次。 好久没写矩阵乘法了。顺便当模板敲一次。View Code #include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;const int inf = 0x3f3f3f3f;cons 阅读全文
posted @ 2013-04-22 22:47 yefeng1627 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 乱搞.#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<cmath>#include<stack>using namespace std;const double Pi = acos(-1);const double eps = 1e-8;char str[310][10];int n, m;int sign(double x){ return x<-eps?-1:(x>eps);}stack<dou 阅读全文
posted @ 2013-04-22 21:18 yefeng1627 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题意: N个顶点(N<=10000),N-1条边,每条边含有一个权值,有T个基地,需要删除K条边,形成K+1个连通块,使每个连通块包含至少一个基地. 求最小花费.解法: 还是太弱. 看完题没敢想 O(N^2)的算法,最初想建模求最小割,后面又想到点分治,但是O(N^2)的空间复杂度。。。。。 其实题目给了10S, 将所有边从小到大排序后, 尝试删除该边,若此边两端 联通快,都包含基地,则删除. 处理出来K+1个联通块就是答案了.View Code #include<cstdio>#include<cstdlib>#include<cstring>#in 阅读全文
posted @ 2013-04-22 20:02 yefeng1627 阅读(140) 评论(0) 推荐(0) 编辑

Launch CodeCogs Equation Editor