摘要: Robberieshttp://acm.hdu.edu.cn/showproblem.php?pid=2955背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱最脑残的是把总的概率以为是抢N家银行的概率之和…把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋);正确的方程是:f[j]=max(f[j],f[j-q[i].money]*q[i].v)其中,f[j]表示抢j块大洋的最大的逃脱概率,条件是f[j-q[i].money]可达,也就是之前抢劫过;始化为:f[0]=1,其 阅读全文
posted @ 2011-09-04 19:47 Firecoder 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 容易:1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740, 1742, 1887, 1926, 1936, 1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029, , 2063, 2081, 2082, 2181, 2184, 2192, 2231, 2279, 2329, 2336, 2346, 2353, 2355, 2 阅读全文
posted @ 2011-09-04 19:46 Firecoder 阅读(157) 评论(0) 推荐(0) 编辑
摘要: poj 2186 Popular Cows强连通分量 tarjanhttp://poj.org/problem?id=2186#include <iostream>#include "stdio.h"#include "string.h"using namespace std;struct node{ int v, next;}edge[50000];const int MAXV = 10001;int adj[MAXV], lp, low[MAXV], dfn[MAXV], out[MAXV], belong[MAXV], stack[MA 阅读全文
posted @ 2011-08-17 14:24 Firecoder 阅读(141) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3714#include "stdio.h"#include "cmath"#include "iostream"#include "algorithm"using namespace std;struct point{ long long x, y; bool flag;};point p[200003];point tp[200003];bool cmp_x(const point & a, const point & b) { return 阅读全文
posted @ 2011-08-15 12:08 Firecoder 阅读(144) 评论(0) 推荐(0) 编辑
摘要: hdu 1007 Quoit Design (最近点对)http://acm.hdu.edu.cn/showproblem.php?pid=1007“最近点对”的经典入门题所用到的思想和“归并排序”类似, 分治再合并。#include "stdio.h"#include "cmath"#include "iostream"#include "algorithm"using namespace std;struct point {double x, y;};point p[100003];point tp[10000 阅读全文
posted @ 2011-08-15 11:14 Firecoder 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 文章来源: http://hi.baidu.com/studyrush/blog/item/08ba35012c755383d43f7ce2.html最短路问题此类问题类型不多,变形较少POJ 2449 Remmarguts' Date(中等)http://acm.pku.edu.cn/JudgeOnline/problem?id=2449题意:经典问题:K短路解法:dijkstra+A*(rec),方法很多相关:http://acm.pku.edu.cn/JudgeOnline/showcontest?contest_id=1144该题亦放在搜索推荐题中POJ 3013 - Big 阅读全文
posted @ 2011-08-10 17:03 Firecoder 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 文章来源:http://hi.baidu.com/novosbirsk/blog/item/723a9727a9ab8804918f9dca.html其实也谈不上推荐,只是自己做过的题目而已,甚至有的题目尚未AC,让在挣扎中。之所以推荐计算几何题,是因为,本人感觉ACM各种算法中计算几何算是比较实际的算法,在很多领域有着重要的用途(例如本人的专业,GIS)。以后若有机会,我会补充、完善这个列表。计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板很重要,模板必须高度可靠。3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面大部分是模板。如果代 阅读全文
posted @ 2011-08-08 19:58 Firecoder 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 文章来源:http://www.byvoid.com/blog/scc-tarjan/ (BYVoid 原创作品,转载请注明。)[有向图强连通分量]在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。非强连通图有向图的极大强连通子图,称为强连通分量(strongly connected components)。下图中,子图{1,2,3,4}为一个强连通分量,因为顶点1,2,3,4两两可达。{5},{6}也分别是两个强连通分量。直接根据定义,用双向遍历取交集的方法求强连通分量,时间复杂度为O 阅读全文
posted @ 2011-08-08 09:40 Firecoder 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 经典的欧拉回路题http://poj.org/problem?id=1041欧拉回路:每条边经过一次且仅一次的称为欧拉回路(euler cycle, euler circuit)。存在欧拉回路的充要条件:每个点的度数都是偶数, 且图连通。#include "iostream"#include "stdio.h"#include "string.h"#include "algorithm"using namespace std;int G[50][2000]; //G[点][边] = 点,这样是为了能方便让边lexi 阅读全文
posted @ 2011-08-04 18:56 Firecoder 阅读(153) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3267#include "stdio.h"#include "iostream"#include "string.h"using namespace std;char dict[610][30]; //the cows' dictionarychar seq[310]; //the received messageint dp[310];int min(int a, int b){ return a < b ? a : b;}int main(){ int n, L, 阅读全文
posted @ 2011-08-04 11:59 Firecoder 阅读(128) 评论(0) 推荐(0) 编辑