上一页 1 ··· 121 122 123 124 125 126 127 128 129 ··· 182 下一页
摘要: 匈牙利,似乎还是有多余空格View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 55char map[maxn][maxn];bool chk[maxn][maxn];int match[maxn][maxn];int tot, n, m;int dir[4][2] ={{ 0, 1 },{ 1, 0 },{ -1, 0 },{ 0, -1 } };void input() 阅读全文
posted @ 2011-06-25 22:08 undefined2024 阅读(337) 评论(0) 推荐(0)
摘要: 最小生成树,要注意多余的空格(包括x,y那行)View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105#define inf 0x3f3f3f3fstruct Point{ int x, y;} point[maxn], q[maxn * maxn];int n, m;bool map[maxn][maxn];int dist[maxn][maxn];char st[m 阅读全文
posted @ 2011-06-25 21:28 undefined2024 阅读(411) 评论(0) 推荐(1)
摘要: 题意:ABC三个物种构成循环捕食的食物网。给出一些捕食与同类 关系,询问一些关系是否正确。分析:并查集,但要随时记录并更新每个元素与其父亲之间的关系。用rank数组记录与父亲的关系。若为rank[x]==1则x吃其父亲,0表示同类,-1表示被吃。我们认为并查集中每个集合中的所有的动物都站在一条数轴上,每个点可以站多个动物,他们占据了一些连续的点。若b在a的右邻位则b吃a,若a,b相距是3的整数倍,则ab同类。这样以来rank数组的意义就变成了该动物与其父亲的在数轴上的差距(有正负)。当我们确定了a,b到祖先的距离时,只需要用rank[a]-rank[b]就可以获得a到b的距离。View Cod 阅读全文
posted @ 2011-06-25 19:04 undefined2024 阅读(187) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105int sum[maxn][maxn], a[maxn][maxn];int main(){ //freopen("t.txt", "r", stdin); int n; scanf("%d", &n); for (int i = 1; i 阅读全文
posted @ 2011-06-25 16:48 undefined2024 阅读(351) 评论(0) 推荐(1)
摘要: 动态规划View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxv 305#define maxp 35int cost[maxp][maxv];int d[maxv][maxv];int village[maxv];int v, p;int main(){ //freopen("t.txt", "r", stdin); scanf(&qu 阅读全文
posted @ 2011-06-25 16:42 undefined2024 阅读(381) 评论(1) 推荐(0)
上一页 1 ··· 121 122 123 124 125 126 127 128 129 ··· 182 下一页