摘要: 首先抽象一个超级源点S,他向所有源点都有一条有向边。然后就是建立一棵树,使得这棵树满足对于每个节点,在有向可拓扑图中说删掉他而使得源点不可达的节点都是以他为根的这棵子树中的节点。建立这棵树的做法就是先将原图拓扑排序一次,然后按照拓扑序依次处理每个点,由于拓扑序的原因,每当处理到一个点,当前点的父节点一定在当前已建的树上,然后当前点的所有食物在这棵树上的最近公共祖先就是当前点的父节点。/** * Problem:catas * Author:Shun Yao * Time:2013.6.3 * Result:Accepted * Memo:graphs */#include <cstrin 阅读全文
posted @ 2013-06-03 15:34 hsuppr 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 看懂题意就好了。就是相邻的城市连边,然后求图的直径。/** * Problem:Journey * Author:Shun Yao * Time:2013.6.3 * Result:Accepted */#include <cstring>#include <cstdio>#include <algorithm>const long Maxn = 200005;long abs(long x) { return x < 0 ? -x : x;}long max(long x, long y) { return x > y ? x : y;}lon 阅读全文
posted @ 2013-06-03 15:28 hsuppr 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 好题,看出来实际是个堆的种数,忘了组合数。。/** * Problem:Magic * Author:Shun Yao * Time:2013.6.2 * Result:Accepted * Memo:DP, Math */#include <cstdio>#include <cmath>const long Maxn = 1000005;long min(long x, long y) { return x < y ? x : y;}long n;long long p, f[Maxn], d[Maxn], jc[Maxn];void exgcd(long lo 阅读全文
posted @ 2013-06-03 15:22 hsuppr 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 一眼数位dp,但。。。调试了好久。。/** * Problem:Count * Author:Shun Yao * Time:2013.5.31 * Result:Accepted * Memo:DP */#include <cstdio>#include <cstring>long long ans[10], s[15], tmp[10], f[15][10][10];void calc(long long b, char y) { long i, j, l, t, k; long long q; if (b == 0) { if (y) ++ans[0]; else 阅读全文
posted @ 2013-06-03 15:10 hsuppr 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 一眼二分图,匈牙利上。/** * Problem:Holiday * Author:Shun Yao * Time:2013.5.31 * Result:Accepted * Memo:matching */#include <cstring>#include <cstdio>#include <cmath>const long Maxt = 55, Maxm = 2505;long n, wt, used[Maxt];char vis[Maxt], a[Maxt], c[Maxt];long tot;class gnode {public: long v; 阅读全文
posted @ 2013-06-03 15:09 hsuppr 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 恶心啊,居然找规律。/** * Problem:function * Author:Shun Yao * Time:2103.5.31 * Result:Accepted */#include <cstdio>long min(long x, long y) { return x < y ? x : y;}int main() { long n, k; freopen("function.in", "r", stdin); freopen("function.out", "w", stdout); 阅读全文
posted @ 2013-06-03 15:07 hsuppr 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 看题时像一个独立集的题,看了数据之后。。。。主要在于:每个骑士都有且仅有一个自己最厌恶的骑士。所以整个图是多个联通块,每联通块都是一个环和一些树。先在树上做dp,可以枚举环上两点,分别不取。也可以写个环dp。(我写的是环dp)/** * Problem:[ZJOI2008]p5 * Author:Shun Yao * Time:2013.5.30 * Result:Accepted * Memo:DP */#include <cstring>#include <cstdio>const long Maxn = 1000005;long long max(long lon 阅读全文
posted @ 2013-06-03 15:03 hsuppr 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 用每条相邻两点所构成的直线维护一个下凸。主要注意凸包的点与地面的高度差,地面的拐点与凸包的高度差。/** * Problem:[JLOI2013]Tower * Author:Shun Yao * Time:2013.5.30 * Result:Accepted */#include <cstring>#include <cstdlib>#include <cstdio>#include <algorithm>const long Maxn = 305;double abs(double x) { return x < 0 ? -x : x 阅读全文
posted @ 2013-06-03 14:56 hsuppr 阅读(311) 评论(0) 推荐(0) 编辑
摘要: dp,f[i][j][k][l]表示前i个人,j个男生,后缀中男生比女生最多多k人,最少少l人的方案数。/** * Problem:Party * Author:Shun Yao * Time:2013.5.30 * Result:Accepted * Memo:DP */#include <cstring>#include <cstdlib>#include <cstdio>long min(long x, long y) { return x < y ? x : y;}long max(long x, long y) { return x > 阅读全文
posted @ 2013-06-03 14:50 hsuppr 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 贪心, 最强/最弱的能赢就打,否则自己最弱的打对手最强的。/** * Problem:BNB * Author:Shun Yao * Time:2013.5.30 * Result:Accepted * Memo:greedy */#include <cstdio>#include <algorithm>long n, x[100000], y[100000];long solve(long A[], long B[]) { static long ret, i, j, k, l; ret = i = j = 0; k = l = n - 1; while (i < 阅读全文
posted @ 2013-06-03 14:45 hsuppr 阅读(181) 评论(0) 推荐(0) 编辑