摘要: 思路:从当前的某一点出发,每次选择当前能到达最小值的点,然后标记访问过的点和更新能到达的点,重复执行直至所有点都被访问过。代码:#includeusing namespace std;const int maxn = 1000+10;const int INF = 0x3fffffff; // 无穷的一半int map[maxn][maxn]; //存图int dis[maxn];int visited[maxn];int m,n;void init(){ //map的初始化 for(int i=1; i map[t][k]){ //没有使用过并且比当前更优时替换 dis[k] = map[t 阅读全文
posted @ 2013-10-21 09:02 静坐观雨 阅读(213) 评论(0) 推荐(0)
摘要: 杭电Common Subsequence(1159):题意:求两个字符串的最大公共子串。Sample:abcfbc abfcabprogramming contestabcd mnp420代码:#include#includeusing namespace std;const int MAX = 1000 + 10;char a[MAX];char b[MAX];int DP[MAX][MAX];int Max(int x, int y){ //求最大值 return x > y ? x : y;}int main(){ while(cin>>a>>b){ int 阅读全文
posted @ 2013-10-21 08:20 静坐观雨 阅读(383) 评论(0) 推荐(0)