![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
shuangde800
这个作者很懒,什么都没留下…
展开
-
Havel-Hakimi定理
Havel定理描述给定一个非负整数序列{d1,d2,...dn},若存在一个无向图使得图中各点的度与此序列一一对应,则称此序列可图化。进一步,若图为简单图,则称此序列可简单图化。可图化的判定比较简单:d1+d2+...dn=0(mod2)。关于具体图的构造,我们可以简单地把奇数度的点配对,剩下的全部搞成自环。可简单图化的判定,有一个Havel定理,是说: 我们把序列排成原创 2012-08-12 15:55:17 · 11156 阅读 · 1 评论 -
UVa 10026 - Shoemaker's Problem
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=967类型: 贪心原题:Shoemaker has N jobs (orders from customers) which he mus原创 2012-08-12 01:17:34 · 1740 阅读 · 0 评论 -
UVa 10954 - Add All
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1895原题:Yup!! The problem name reflects your task; just add a set of numbers原创 2012-08-13 08:08:11 · 1626 阅读 · 0 评论 -
UVa 10706 - Number Sequence
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1647原题:A single positive integer i is given. Write a program to find the di原创 2012-08-14 23:59:02 · 1323 阅读 · 0 评论 -
UVa 10602 - Editor Nottoobad
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1543类型:贪心原题:Company Macrohard has released it’s new version of editor原创 2012-08-15 00:22:44 · 1370 阅读 · 0 评论 -
UVa 10382 - Watering Grass
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1323原题:n sprinklers are installed in a horizontal strip of grass l meters l原创 2012-08-15 00:54:08 · 4429 阅读 · 5 评论 -
UVa 311 - Packets
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=247原题:A factory produces products packed in square packets of the same heig原创 2012-08-15 10:32:48 · 1907 阅读 · 0 评论 -
poj 1456 Supermarket (贪心, 并查集)
链接: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 a原创 2012-09-27 00:06:05 · 5140 阅读 · 4 评论 -
UVa 11729 Commando War
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2829/* 刘汝佳《训练指南》第一章 例题2 UVa 11729 Commando War 贪心 , 用“相邻交换法”证明正确性原创 2012-12-06 23:07:12 · 968 阅读 · 0 评论 -
UVa 11292 - Dragon of Loowater
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2267/* 《算法竞赛入门经典-训练指南》 第一章 例题1 排序+贪心 by shuangde*/#include#inc原创 2012-12-06 18:36:48 · 667 阅读 · 0 评论 -
uva 1344 Tian Ji -- The Horse Racing
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4090思路:分别把田忌和国王的马按速度从小到达排序,然后开始从第一个比较,也就是田忌中最小的马和国王最小的马比较,速度分别设为s1, s2,如果s1s2,那么反正这匹马都是输,就让这匹马原创 2013-03-08 21:45:33 · 1269 阅读 · 0 评论 -
uva 11134 Fabled Rooks
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2075题目大意:在一个n*n的棋盘上放置n个车,使得它们之间都不能互相攻击(任意两个车都不能同行或同列),并且,对于第i个车,限制它只能放在一个矩形区域内,(xl原创 2013-03-09 14:55:08 · 2677 阅读 · 0 评论 -
uva 10037 Bridge
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=978题目大意:在夜晚有n个人过桥,但是只有一个手电筒,所以每次只能两个人过去,然后过去的一个人再把手电筒带过来,依次进行,知道所有人都过去。由于每个人的过桥速度不同,所以每一组的速度取决原创 2013-03-10 20:22:02 · 1494 阅读 · 0 评论 -
uva 11520 - Fill the Square
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=2515题目大意:给一个矩阵,要求在上面填上A到Z的字母,使得每个格子的字母与其相邻格子的字母不同。思路:直接按照从左到右,从上到下的顺序原创 2013-03-14 20:59:07 · 1305 阅读 · 0 评论 -
uva 1267 Network
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=3708思路:先把无根树转化为以s点为根的有根树然后从深度最深的叶子节点开始枚举,如果这个叶子节点还没被覆盖掉的话,那么找它的祖先距离小于等于k的点,然后原创 2013-03-15 13:34:01 · 941 阅读 · 0 评论 -
uva 1335 - Beijing Guards
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=4081好题!不得不说贪心真的很强大和千变万化。。。1. 二分答案p,编号为偶数的尽量往前取,编号为奇数个的尽量往后取。2. 第一个取第1~r原创 2013-03-22 22:25:40 · 1363 阅读 · 0 评论 -
UVa 270 - Lining Up
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=206原题:``How am I ever going to solve this problem?" said the pilot.Inde原创 2012-08-14 10:51:44 · 1450 阅读 · 0 评论 -
UVa 10148 - Advertisement
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1089【原题】The Department of Recreation has decided that it must be more profit原创 2012-08-18 00:12:42 · 2174 阅读 · 0 评论 -
UVa 10716 - Evil Straw Warts Live
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1657【原题】A palindrome is a string of symbols that is equal to itself when原创 2012-08-17 00:01:59 · 1724 阅读 · 1 评论 -
poj 1659 Frogs' Neighborhood
题目链接:http://poj.org/problem?id=1659类型: 贪心,Havel-Hakimi定理题目:Description未名湖附近共有N个大小湖泊L1, L2, ..., Ln(其中包括未名湖),每个湖泊Li里住着一只青蛙Fi(1 ≤ i ≤ N)。如果湖泊Li和Lj之间有水路相连,则青蛙Fi和Fj互称为邻居。现在已知每只青蛙原创 2012-08-12 15:59:49 · 885 阅读 · 0 评论 -
UVa 108 - Maximum Sum
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=44原题:BackgroundA problem that is simple to solve in one dimension is of原创 2012-08-14 00:23:44 · 3601 阅读 · 1 评论 -
UVa 10714 - Ants
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1655原题:An army of ants walk on a horizontal pole of length l cm, each wit原创 2012-08-13 00:23:00 · 4157 阅读 · 2 评论 -
UVa 507 - Jill Rides Again
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=448类型: 最大连续和原题:Jill likes to ride her bicycle, but since the原创 2012-08-14 00:18:23 · 1832 阅读 · 0 评论 -
UVa 10827 - Maximum sum on a torus
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1768原题:A grid that wraps both horizontally and vertically is called a tor原创 2012-08-14 00:49:18 · 2390 阅读 · 0 评论 -
UVa 10720 - Graph Construction
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1661原题:Graph is a collection of edges E and vertices V. Graph has a wide va原创 2012-08-12 23:58:56 · 1456 阅读 · 0 评论 -
UVa 10020 - Minimal coverage
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=961类型: 贪心原题:The ProblemGiven several segments of line (int the X原创 2012-08-13 00:04:49 · 1568 阅读 · 2 评论 -
UVa 10132 - File Fragmentation
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1073类型: 贪心+回溯原题:The ProblemYour friend, a biochemistry major, tri原创 2012-08-14 10:43:59 · 1195 阅读 · 0 评论 -
UVa 714 - Copying Books,最大值最小化问题
链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=655原题:Before the invention of book-printing, it was very hard to make a cop原创 2012-08-15 00:07:14 · 7129 阅读 · 3 评论 -
UVa 993 - Product of digits
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=934【原题】For a given non-negative integer number N , find the minimal natura原创 2012-08-16 00:40:36 · 1604 阅读 · 0 评论 -
UVa 11100 - The Trip, 2007
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=2041【原题】A number of students are members of a club that travels annually to原创 2012-08-17 00:15:54 · 1970 阅读 · 0 评论 -
UVa 757 - Gone Fishing
【题目链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=698【原题】John is going on a fishing trip. He has h hours available ( ),原创 2012-08-17 01:26:33 · 2205 阅读 · 0 评论 -
UVa 11054 - Wine trading in Gergovia
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1995【原题】As you may know from the comic "Asterix and the Chieftain's Shield原创 2012-08-16 00:21:25 · 1975 阅读 · 0 评论 -
UVa 10718 - Bit Mask
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1659【原题】In bit-wise expression, mask is a common term. You can get a c原创 2012-08-16 00:04:23 · 2152 阅读 · 0 评论 -
UVa 10041 - Vito's Family
【链接】http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=982【原题】Background The world-known gangster Vito Deadstone is moving to New原创 2012-08-17 01:04:19 · 1492 阅读 · 0 评论 -
UVa 10670 - Work Reduction
【链接】UVA: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1611poj: http://poj.org/problem?id=1907【原题】Paperwork is beginnin原创 2012-08-16 00:29:04 · 1660 阅读 · 0 评论 -
zoj 3627 Treasure Hunt II (贪心)
题意 直线上有n个城市, 第i个城市和i+1个城市是相邻的. 每个城市都有vi的金币. Alice和Bob站在城市p, 他们每天可以选择走向一个相邻的城市, 也可以选择不走. 他们是单独行动的. 他们经过一个城市就可以获得相应的金币(不能重复获得) 作为一个队伍, 他们的最远距离不能操作M, 问T天内, 他们最多一共能拿多少金币?思路 由于每次只能走一步,那么一定是一个人往左走,一个人往右走,因为如果两个人一起往同一个方向走, 那么就和一个人一起走的效果是一样原创 2013-08-27 00:14:46 · 2555 阅读 · 2 评论