摘要: 题意: 有n 个城市,一开始每个城市有一颗龙珠,有 m 个操作 T a b 将a城市的所有龙珠转移到 b 城市 Q a 输出a龙珠所在的城市,和该城市现有的龙珠的数量,和该龙珠被转移的次数分析: 并查集,x 的祖先f[x]记录x 所在城市,每次合并的时候更新路径上的点#include<stdio.h>#include<string.h>#define maxn 10011int city[maxn];int move[maxn];int f[maxn];int find(int x){ if(f[x]==x) return x; int t=f[x]; ... 阅读全文
posted @ 2012-09-04 23:48 'wind 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题意: 求出包含样例所有子串的字符串的最小长度。分析: dp[i][j]表示在 i 状态下 ,以第 j 个字符串结尾的最优值。#include<stdio.h>#include<string.h>#define INF 0x1f1f1f1f#define clr(x)memset(x,0,sizeof(x))int min(int a,int b){ return a<b?a:b;}int dp[1<<16][16];int g[16][16];int add_s(char *s1,char *s2) // 求出 s2 串加在s1 串后增加的长度{ i 阅读全文
posted @ 2012-09-04 21:01 'wind 阅读(240) 评论(0) 推荐(0) 编辑