POJ 2235 Frogger / UVA 534 Frogger /ZOJ 1942 Frogger(图论,最短路径) Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty a…
说明:关于Uva的题目,可以在vjudge上做的,不用到Uva(那个极其慢的)网站去做. 最小瓶颈路:找u到v的一条路径满足最大边权值尽量小 先求最小生成树,然后u到v的路径在树上是唯一的,答案就是这条路径. Uva 534 Frogger Time Limit: 3000MS 64bit IO Format: %lld & %llu Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly h…
UVA 534 - Frogger 题目链接 题意:给定一些点.如今要求一条路径从第一个点能跳到第二个点,而且这个路径上的最大距离是最小的 思路:利用kruskal算法,每次加最小权值的边进去,推断一下是否能联通两点,假设能够了,当前权值就是答案复杂度为O(n^2log(n)) 可是事实上这题用floyd搞搞O(n^3)也能过啦. .只是效率就没上面那个方法优了 代码: #include <cstdio> #include <cstring> #include <cmath&…
POJ 1797 Heavy Transportation / SCU 1819 Heavy Transportation (图论,最短路径) Description Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there reall…
题意:平面上有N个石头,给出坐标.一只青蛙从1号石头跳到2号石头,使路径上的最长便最短.输出这个值.(2≤N≤200) 解法:最小瓶颈树.而由于这题N比较小便可以用2种方法:1.最短路径中提到过的Floyd算法,利用DP思想枚举出所有情况,O(n3).具体关于Floyd算法的一些解释得等我过几天写一篇博文.2.用Kruskal算法求出最小生成树再求出路径上的最长边权.具体解释见我之前的一篇博文: 关于生成树的拓展 {附[转]最小瓶颈路与次小生成树}(图论--生成树) 1 #include<cst…
两题很有趣挺经典的蚂蚁问题. 1.n只蚂蚁以1cm/s的速度在长为L的竿上爬行,当蚂蚁爬到竿子的端点就会掉落.当两只蚂蚁相撞时,只能各自反向爬回去.对于每只蚂蚁,给出距离左端的距离xi,但不知道它的朝向,求所有蚂蚁落下竿子所需要的时间的最大值和最小值. 2.问题1的升级版:把问题1改为已知每只蚂蚁的左端距离和它的朝向,要求按输入顺序输出 t 秒后每只蚂蚁的位置和状态(掉出去,转向中,或者蚂蚁的朝向). 1.POJ 1852 Ants http://poj.org/problem?id=1852…
http://poj.org/problem?id=1364 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=456 题目大意: 有一串序列,A={a1,a2,--an}; 然后给你一些信息,判断是否有解 4 2  1 2 gt 0   表示a1+a2+a3>0 2 2 lt 2    表示 a2+a3+a4<2 思路: 还是差分…
*注 虽然没什么人看我的博客但我还是要认认真真写给自己看 背包问题应用场景给定 n 种物品和一个背包.物品 i 的重量是 w i ,其价值为 v i ,背包的容量为C.应该如何选择装入背包中的物品,使得装入背包的总价值最大?*01 背包 *01 背包特点: 给定 n 种物品和一个背包 ( 每个物品只能选取一个).物品 i 的重量是w[i],其价值为v[i],背包的容量为C.应该如何选择装入背包中的物品,使得装入背包中的物品的总价值最大?*状态: dp[i][j] 表示在只能从 1-i 个物品中选…
题目链接:http://poj.org/problem?id=3522 Slim Span Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7522   Accepted: 3988 Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G…
这场比赛可以说是灰常的水了,涨信心场?? 今下午义务劳动,去拿着锄头发了将近一小时呆,发现自己实在是干不了什么,就跑到实验室打比赛了~ 之前的比赛补题补了这么久连一场完整的都没补完,结果这场比完后一小时连题解都出来了··· A-烤肉拌饭 ( uva 572) 就是求联通块的数量啊,刚学dfs的时候做的那种! #include <cstdio> #include <algorithm> #include <cstring> #include <iostream>…
Tree Summing Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8132   Accepted: 1949 Description LISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the oldest languages currently being used. Lists, w…
http://poj.org/problem?id=3090 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1777 题目大意: 给你一个坐标系和一个范围,求x.y在[0,N]这个范围内,未被挡住点的个数. 被挡住的点定义为:从原点引一条射线到某个点,若之前经过其他的点,则被挡住. 思路: 未被挡住的一定是互质的(由斜率可以想到) 然后直接打表吧. #include<cstdio> const int MAXN=1002;…
http://poj.org/problem?id=1775 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1334 题目大意: 给一个数n看看n是否能够拆成几个阶乘的和 如9=1!+2!+3! 方法一: 最初想法是直接打出0~10的阶乘,10的阶乘已经大于n的范围 然后DFS,也过了.不过时间好惨... 注意n=0输出NO和0!=1 #include<cstdio> #include<cstring> con…
floyd算法 数据量比较小  就简单了~ /************************************************************************* > Author: xlc2845 > Mail: xlc2845@gmail.com > Created Time: 2013年10月31日 星期四 13时55分07秒 ***************************************************************…
题目链接:http://poj.org/problem?id=3311 题目大意:一个送披萨的,每次送外卖不超过10个地方,给你这些地方之间的时间,求送完外卖回到店里的总时间最小. Sample Input 3 0 1 10 10 1 0 1 2 10 1 0 10 10 2 10 0 0 Sample Output 8 分析:dp[i][j]:表示在i状态(用二进制表示城市有没有经过)时最后到达j城市的最小时间,转移方程:dp[i][j]=min(dp[i][k]+d[k][j],dp[i][…
一.Description Stockbrokers 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 in the stock market. For maximum effect, you have…
Problem B: The Largest Clique Given a directed graph G, consider the following transformation. First, create a new graph T(G) to have the same vertex set as G. Create a directed edge between two vertices u and v in T(G) if and only if there is a path…
Domino Effect Time Limit: 2 Seconds      Memory Limit: 65536 KB Did you know that you can use domino bones for other things besides playing Dominoes? Take a number of dominoes and build a row by standing them on end with only a small distance in betw…
Description Have you ever thought about comparing the weight of fruits? That’s what you should do in this problem! Given a series of fruit weight comparisons, you should anticipate the result of another comparison. In this problem, all fruits of the…
Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15989   Accepted: 7303 Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X …
题意:有一个水塘,要求把它用围栏围起来,每个费用为b.其中,(#)代表草,(.)代表洞,把一个草变成洞需要费用d, 把一个洞变成草需要费用f.请输出合法方案中的最小费用. 解法:(不好理解......('・ω・')っ) [思考]    1.围栏把草和洞分隔开了,也就是"割".但"割"只是把图中的点分成两部分,而这题的草和洞能有多个连通块.因此可以添加源.汇点,使得所有的草和洞接连起来了.    2.先考虑草和洞不能互相转换,那么只有建围栏这一种"割&quo…
题意:有一个N行M列的正整数矩阵,输入N个前1~N行所有元素之和,以及M个前1~M列所有元素之和.要求找一个满足这些条件,并且矩阵中的元素都是1~20之间的正整数的矩阵.输入保证有解,而且1≤N,M≤20. 解法:这题的图转换得极妙!(*^▽^*)   我们可以发现找到的矩阵需要满足3个条件:1.N行M列:2.各行各列的和:3.各元素的大小.再仔细阅读一次题目,发现题目中提到的2个数字相同--"20",再想想这是不是有什么玄机.     首先可以找到第3个条件的转化,可以用容量来限制,…
题意:有N个人互相打了M次电话,请找出所有电话圈(Eg.a→b,b→c,c→d,d→a 就算一个电话圈)并输出.(N≤25,L≤25,注意输出格式) 解法:由于N比较小所有n^2或n^3的复杂度都没有问题.所以就O(n^2)读入:O(n^3)Floyd算法求出传递闭包,d[i][j]表示 i 是否直接或间接给 j 打过电话,并查集并起一个电话圈里的人:O(n^2)输出.总的是O(n^3)的时间复杂度. P.S.我的代码有点长~再补个连通分量和强连通分量的知识:连通分量--强连通图的连通分量为其本…
题意:给一个N(N<=100)个点的联通图(无自环和平行边),求苗条度(最大边-最小边的值)尽量小的生成树. 解法:枚举+Kruskal.先从小到大排序边,枚举选择的最小的边. 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<algorithm> 5 #include<iostream> 6 using namespace std; 7 const…
POJ 2296 Map Labeler / ZOJ 2493 Map Labeler / HIT 2369 Map Labeler / UVAlive 2973 Map Labeler(2-sat 二分) Description Map generation is a difficult task in cartography. A vital part of such task is automatic labeling of the cities in a map; where for e…
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For exa…
POJ 1860 Currency Exchange / ZOJ 1544 Currency Exchange (最短路径相关,spfa求环) Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations onl…
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find The MultiplePOJ 3126 Prime PathPOJ 3087 Shuffle'm UpPOJ 3414 PotsFZU 2150 Fire GameUVA 11624 Fire!POJ 3984 迷宫问题HDU 1241 Oil Deposit…