摘要:
矩阵里的数字代表当前点的高度,只能从高的点滑到低的点,求最长能滑的距离。初始点不规定。我们可以向每个点的四周搜索,能走则就在当前距离加1。并将已经求的值保存在二维数组中。(记忆化搜索)/*Accepted 252K 47MS C++ 1158B 2012-07-23 16:13:17*/#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;const int MAXN = 105;const int dx[] = {0, 0 阅读全文
posted @ 2011-12-15 23:27
找回失去的
阅读(133)
评论(0)
推荐(0)
摘要:
这道题是判断无向图是否存在欧拉回路:所有的点的度数(出度和入度之和)为偶数。所有的点都在一个集合中。#include<cstdio>#include<cstring>#include<cstdlib>#define MAXN 205int d[MAXN], p[MAXN];int N, R;int find_set( int x){ return p[x] == x ? x : ( p[x] = find_set( p[x]) );}void union_set( int x, int y){ x = find_set( x); y = find_set( 阅读全文
posted @ 2011-12-15 09:58
找回失去的
阅读(266)
评论(0)
推荐(1)
浙公网安备 33010602011771号