ACM算法
文章平均质量分 63
smallacmer
这个作者很懒,什么都没留下…
展开
-
The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest &&Dave
Problem DescriptionRecently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground.原创 2011-09-23 19:25:11 · 704 阅读 · 0 评论 -
poj习题分类
初期:一.基本算法:(1)枚举. (poj1753,poj2965)(2008-10-27Done 位运算+宽搜)(2)贪心(poj1328,poj2109,poj2586)(3)递归和分治法.(4)递推.(5)构造法.(poj3295)(6)模拟法.原创 2011-10-11 21:00:01 · 1044 阅读 · 0 评论 -
poj&&1753
http://poj.org/problem?id=1753DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16原创 2011-10-13 11:40:31 · 498 阅读 · 0 评论 -
ACM题库以及培养策略
ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge。除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库。USACOhttp://ace.delos.com/usacogate美国著名原创 2011-10-16 11:01:07 · 4905 阅读 · 1 评论 -
http://poj.org/problem?id=2965
DescriptionThe game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.The原创 2011-10-14 18:47:10 · 601 阅读 · 0 评论 -
经典ACM算法
实验一 统计数字问题 实验二 最大间隙问题 实验三 众数问题 实验四 半数集问题 实验五 集合划分问题 实验六 最少硬币问题 实验七 编辑距离问题 实验八 程序存储问题原创 2011-10-16 11:12:24 · 3309 阅读 · 1 评论 -
dijkstra 求最短路径算法
Dijkstra(迪杰斯特拉)算法是典型的最短路径路由算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法能得出最短路径的最优解,但由于它遍历计算的节点很多,所以效率低。Dijkstra算法是很有代原创 2011-10-18 18:12:22 · 968 阅读 · 0 评论 -
http://poj.org/problem?id=2075
DescriptionYou are the owner of SmallCableCo and have purchased the franchise rights for a small town. Unfortunately, you lack enough fu原创 2011-10-19 11:30:15 · 535 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=115&&Dijkstra城市平叛
南将军统领着N个部队,这N个部队分别驻扎在N个不同的城市。他在用这N个部队维护着M个城市的治安,这M个城市分别编号从1到M。现在,小工军师告诉南将军,第K号城市发生了暴乱,南将军从各个部队都派遣了一个分队沿最近路去往暴乱城市平乱。现在已知在任意两个城市之间原创 2011-10-18 16:55:20 · 1383 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=38&&最小生成树
描述 南阳理工学院要进行用电线路改造,现在校长要求设计师设计出一种布线方式,该布线方式需要满足以下条件:1、把所有的楼都供上电。2、所用电线花费最少输入 第一行是一个整数n表示有n组测试数据。(n每组测试数据的第一行是两个整数v,e.v表示学校里楼原创 2011-10-18 13:29:43 · 627 阅读 · 0 评论 -
http://poj.org/problem?id=1287&&prim
DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may conne原创 2011-10-20 13:04:12 · 575 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=2066&&多源多点
Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时原创 2011-10-20 21:52:23 · 818 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1233&&Krusal
算是水题。。。。。但自己感觉水的不太好(*^__^*) 嘻嘻……come on #include#include#include#include#define N 5005#define FOR(i,s,t) for(int i=(s);i<=t;++i)using namespace std;int n,m;int father[N];struct edge{int x,y,原创 2011-10-21 09:36:23 · 620 阅读 · 0 评论 -
c++中qsort函数简介
C语言中排序的算法有很多种,系统也提供了一个函数qsort()可以实现快速排序。原型如下: void qsort(void *base, size_t nmem, size_t size, int (*comp)(const void *, const void *)); 它根据comp所指向的函数所提供的顺序对base所指向的数组进行排序,nmem为参加排序的元素个数,size为每个原创 2011-10-19 21:00:35 · 970 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1232&&并查集应用
水题进行时。。。。加油(*^__^*) 嘻嘻……。。。#include#include#include#include#define N 1005#define FOR(i,s,t) for(int i=(s);i<=t;++i)using namespace std;int n,m,tot;int father[N];void make_set(){ FOR(i,1,n原创 2011-10-21 09:20:08 · 986 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=2544&&最短路
水题。。。。dijstra算法。。。。#include#include#include#include#define M 99999999#define N 105#define FOR(i,s,t) for(int i=(s);i<=t;++i)using namespace std;int dist[N];int map[N][N];bool visit[N];in原创 2011-10-20 16:28:29 · 549 阅读 · 0 评论 -
http://poj.org/problem?id=1861&&Kursal
DescriptionAndrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, they can be connected to each other using cables.原创 2011-10-20 12:28:53 · 550 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1874
今天又水了一道dijstra。。。。。。#include#include#include#include#define M 99999999#define N 205#define FOR(i,s,t) for(int i=(s);i<=t;++i)using namespace std;int dist[N];int map[N][N];bool visit[N];i原创 2011-10-21 08:59:44 · 454 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1863
这题也算是一道水题吧!我记得我以前是用Prim算法写的,现在用Kursal写一遍感觉还可以。。。。come on。。。Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成原创 2011-10-21 09:55:41 · 632 阅读 · 0 评论 -
http://poj.org/problem?id=1456&&并查集
DescriptionA supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from t原创 2011-10-22 13:27:23 · 535 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1879
该题依旧是最小生成树问题,只是有一点小小的变化。。。。。做完这题,猛然发现为什么prim算法优先于Kursal了。。。。。#include#include#include#include#define N 105#define FOR(i,s,t) for(int i=(s);i<=t;++i)using namespace std;int n,m;int father[N]原创 2011-10-21 17:26:23 · 627 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1875
Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米原创 2011-10-21 20:06:45 · 592 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=290
描述 在美丽大兴安岭原始森林中存在数量繁多的物种,在勘察员带来的各种动物资料中有未统计数量的原始动物的名单。科学家想判断这片森林中哪种动物的数量最多,但是由于数据太过庞大,科学家终于忍受不了,想请聪明如你的ACMer来帮忙。输入 第一行输入动物名字的数量N(1<= N <= 4000000),接下来的N行输入N个字符串表示动物的名字(字符串的长度不超过10,字符串全为小写字母,并且原创 2011-10-22 21:31:46 · 451 阅读 · 0 评论 -
http://poj.org/problem?id=1125
DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge原创 2011-10-24 20:22:41 · 495 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=401&&简单的博弈论
After hh has learned how to play Nim game, he begins to try another coin game which seems much easier.The game goes like this: Two players start the game with a circle of n coins. They tak原创 2011-10-25 10:48:34 · 484 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=434
一道最小生成树的题,属于模板题,,,,月赛竟然弄了这么长时间,才AC,这道替我用的是prim算法,用krusal也可以,,, #include#include#include#define N 28#define M 99999999using namespace std;int map[N][N];int dist[N];bool visit[N];int n,m;原创 2011-10-24 20:47:39 · 427 阅读 · 0 评论 -
网络流习题集
网络流题目集锦(转)最大流POJ 1273 Drainage DitchesPOJ 1274 The Perfect Stall (二分图匹配)POJ 1698 Alice's ChancePOJ 1459 Power NetworkPOJ 2112 Optimal Milking (二分)POJ 2455 Secret Milking Machine (二分)PO原创 2011-11-15 09:52:21 · 875 阅读 · 0 评论 -
SAP最短增广路算法
#include #include #define msize 1024 //最大顶点数目using namespace std; int d[msize]; //标号int r[msize][msize]; //残留网络,初始为原图int num[msize]; //num[i]表示标号为i的顶点数有多少int pre[msiz原创 2011-11-15 09:50:09 · 1333 阅读 · 0 评论 -
Bellman_ford和SPFA判断是否存在负环
Bellman——ford方法:#include#include#define N 1001using namespace std;struct edge{ int s,e; }aa[N*N]; int map[N][N]; int dist[N]; int bellmam_ford(int start,int end,int n,int m) {原创 2011-10-26 19:54:55 · 732 阅读 · 0 评论 -
初始化测试,memset,for,fill
#include #include #include #include #include #include #include #include #include using namespace std;class Time{ public: void Start() //开始计时 { start_time=cl原创 2011-10-26 10:53:46 · 560 阅读 · 0 评论 -
http://poj.org/problem?id=1273
第一次写最大流的题,,,用的是最复杂的找增光路的方法,,E-K算法,,用bfs找增广路,网络流刚接触路还很长啊,,,加油,,,#include #include #include#include#include#include#define N 205using namespace std;int map[N][N];int n,m;void Ek(){ int f原创 2011-11-15 11:23:06 · 612 阅读 · 0 评论 -
http://poj.org/problem?id=3281
我的最大流的第二题,,,话说刚学网络流,,用了最常用的算法E_k算法还调试了一会,,,,杯具啊,,看了网上大牛们的解题报告,用的都是Dinci和ISPA,,,很是神奇啊,,看来是得学学了,,,这道题难在建图上,,,为了保证每种食物,和饮料只对应一头牛,用了拆点,,,建图顺序为源点-食物-牛-牛-饮料-汇点,,每个弧的容量为1,做完这题我明白了为什么最大二分匹配可以用网络流来做了,,嘎嘎,,,#原创 2011-11-15 15:21:17 · 588 阅读 · 0 评论 -
网络流算法
必须知识:最短路径问题1.Dijkstra适用于满足所有权系数大于等于0(lij≥0)的网络最短路问题,能求出起点v1到所有其他点vj的最短距离;朴素的Dijkstra算法复杂度为O(N^2),堆实现的Dijkstra复杂度为O(NlogN).2.bellman-ford适用于有负权系数,但无负回路的有向或无向网络的最短路问题,能求出起点v1到所有其它点 vj的最短距离转载 2011-11-15 16:04:22 · 558 阅读 · 0 评论 -
二分法求连续字串和
#include#include#define N 999999using namespace std;int a[N];//二分法求最大连续子序列和 int f(int a[],int b,int c){ if(b==c) {if(a[b]>0) return a[b]; else return 0; } int mid=(原创 2011-11-15 16:29:02 · 619 阅读 · 0 评论 -
http://poj.org/problem?id=2983
DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line with N defense stati原创 2011-10-26 21:00:36 · 538 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=13
这一题竟然是Fibonacci数列,纠结啊。。。。很弱啊!!!木有看出来。。。假如铺完除最后一个有f(n-1)种方法,则共有1*f(n-1)中,假如铺完还剩最后两个有f(n-2)这最后两个只有一种,如果竖着铺,就和第一个一样所以只能横着铺,即f(n)=f(n-1)+f(n-2)Ac代码:#includeusing namespace std;long long f[51];原创 2011-10-27 20:52:51 · 493 阅读 · 0 评论 -
http://acm.nyist.net/JudgeOnline/problem.php?pid=239
月老的难题时间限制:1000 ms | 内存限制:65535 KB难度:4描述 月老准备给n个女孩与n个男孩牵红线,成就一对对美好的姻缘。现在,由于一些原因,部分男孩与女孩可能结成幸福的一家,部分可能不会结成幸福的家庭。现在已知哪些男孩与哪些女孩如果结婚的话,可以结成幸福的家庭,月老准备促成尽可能多的幸福家庭,请你帮他找出最多可能促成的幸福家庭数量吧。假设男孩们原创 2011-10-28 20:46:30 · 771 阅读 · 0 评论 -
http://acm.hdu.edu.cn/showproblem.php?pid=1162
最小生成树,水题。。。。。#include#define N 105#define M 9999999.0#define FOR(i,s,t) for(int i=(s);i<=(t);++i)#include#include#includeusing namespace std;double map[N][N];bool visit[N];double dist[N];i原创 2011-10-28 22:00:04 · 572 阅读 · 0 评论 -
SAP模板经典
#include #include #include #include #include #include using namespace std;#define inf 0x7ffffffftypedef long long ll;const int mod=10007;const int N =222;struct po { int b,c; int nxt;原创 2011-11-17 21:51:12 · 665 阅读 · 0 评论 -
实验六—虚函数与多态
#include#include#includeusing namespace std;class animal{ public: animal(){} animal(string s,string s1) {name=s,various=s1;} ~animal(){} voi原创 2011-11-17 18:19:49 · 877 阅读 · 0 评论