
UVA
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【uva-673】 Parentheses Balance(括号匹配问题)
题干:You are given a string consisting of parentheses () and []. A string of this type is said to be correct:(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)if A is correct, (A) ...原创 2018-07-12 23:46:55 · 468 阅读 · 0 评论 -
【UVA - 10037】Bridge(过河问题,经典贪心)
题干:题目大意:有N个人要过桥,每个人速度不同,只有一个手电筒,每次最多只能过去两个人,问所有人最短的过桥时间为多少解题报告: 首先让最快的两个人最后过,然后我们分奇偶考虑,分别处理到剩下三个人和两个人的情况。然后在做最后的处理。 除了最后的处理(其实是最先执行的步骤),我们看其他的步骤,现在最快的俩人都在对岸。 现在两种贪心策略:(一个回合就处理两个人,每个回合把...原创 2018-12-09 13:39:29 · 479 阅读 · 0 评论 -
【UVA - 11292】Dragon of Loowater (贪心,水题,模拟,twopointer双指针)
题干:题目大意:n条恶龙,m个勇士,用勇士来杀恶龙。一个勇士只能杀一个恶龙。而且勇士只能杀直径不超过自己能力值的恶龙。每个勇士需要支付能力值一样的金币。问杀掉所有恶龙需要花费的最少金币。解题报告: twopointer排序后从头到尾扫一遍就行了。AC代码:#include<cstdio>#include<iostream>#include&...原创 2018-12-09 13:29:52 · 288 阅读 · 0 评论 -
【UVA - 1335】Beijing Guards (贪心,二分)
题干:题目大意:有n个人为成一个圈,其中第i个人想要r[i]种不同的礼物,相邻的两个人可以聊天,炫耀自己的礼物。如果两个相邻的人拥有同一种礼物,则双方都会很不高兴,问最少需要多少种不同的礼物才能满足所有人的需求,假设每种礼物有无限多个。 n<=100000解题报告:http://www.cnblogs.com/kickit/p/7619889.htmlhttp://www...原创 2018-12-09 13:29:09 · 308 阅读 · 0 评论 -
【UVA - 10154 】Weights and Measures (贪心排序,dp,类似0-1背包,状态设定思维)
题干:The ProblemMack, in an effort to avoid being cracked, has enlisted your advice as to the order in which turtles should be dispatched to form Yertle's throne. Each of the five thousand, six hund...原创 2018-12-26 15:41:17 · 316 阅读 · 0 评论 -
*【UVA - 10382】Watering Grass(贪心,区间覆盖问题,思维)
题干:题目大意:有一块草坪,长为l,宽为w,在它的水平中心线上有n个位置可以安装喷水装置,各个位置上的喷水装置的覆盖范围为以它们自己的半径ri为圆。求出最少需要的喷水装置个数,如果无论如何都不能覆盖,就输出-1。解题报告: 这题就是个区间覆盖问题的变形,,虽然给的是一个个的圆,但是我们不难发现求出与上下边的交点,这一部分区域才是我们的有效区域,然后求个区间覆盖就行了、、、nlo...原创 2018-12-08 12:59:33 · 354 阅读 · 0 评论 -
【UVA - 11729】Commando War (贪心,时间调度问题)
题干:(Uva不放题干了)题目大意:(实在是自己懒得写网上找了一个)解题报告: 调度问题,直接贪心出完成任务需要的时间最长的那个人排序,就行了。方法正确性的证明以前也写过了,,这里就不再写了,,还是贴那篇题解中附的(这篇题解应该也是采用的交换证明法)。那篇题解AC代码:#include<cstdio>#include<iostream&...原创 2018-12-09 13:26:18 · 392 阅读 · 1 评论 -
【UVA - 10020 】Minimal coverage (贪心,区间覆盖问题)
题干:(Uva题不给题干了) t组样例,每组首先给出一个M,然后给出一些线段(0 0结束),然后问怎么取能使得最少的线段覆盖区间[0, M]。Sample Input21-1 0-5 -32 50 01-1 00 10 0Sample Output010 1 解题报告: 就是个贪心啊AC代码:#include<cstdi...原创 2018-11-29 22:27:54 · 302 阅读 · 0 评论 -
【Uva - 10047 】The Monocycle(搜索,bfs记录状态)
题干:Uva的题目就不粘贴题干了,,直接上题意吧。有你一个独轮车,车轮有5种颜色,为了5中颜色的相对位置是确定的。有两种操作:1.滚动:轮子必须沿着顺时针方向滚动,每滚动一次会到达另一个格子,着地的颜色会改变(顺时针转)。例如当前是绿色着地下一次就是黑色,依次是红蓝白。2.转动:就是改变了轮子的方向(不改变颜色),转动每次只能选择左转90度或者右转90度,即不能掉头。车子每向前走一格(滚动...原创 2018-12-08 10:14:38 · 225 阅读 · 0 评论 -
【UVA - 227】Puzzle (模拟,水题)
题干: Puzzle A children's puzzle that was popular 30 years ago consisted of a 5x5 frame which contained 24 small squares of equal size. A unique letter of the alphabet was printed on each small squar...原创 2018-12-08 10:15:08 · 316 阅读 · 0 评论 -
【UVALive - 3126】Taxi Cab Scheme (二分图,最小路径覆盖)
题目大意:有n个出车安排,一辆车能接到这个安排的条件是:1、这辆车第一次发车;2、这辆车接了上一个安排,回到这个安排的起点的时间正好是这个安排的前一分钟或者更早解题报告: 建图然后跑最小路径覆盖。就是答案。注意搭边的条件不是光看距离,还要加上每个任务的起点到终点的时间。AC代码:(116ms)#include<bits/stdc++.h>using nam...原创 2018-10-25 22:48:32 · 272 阅读 · 0 评论 -
【UVA - 11383】Claw Golden Tiger (二分图最优匹配,KM算法原理)
题干: 粘贴不过来。。。题目大意: 500*500带权格子,每行每列要确定一个值,使row[i]+col[j] >= val[i][j],要使所有row值和col值的和最小输出每行的row[i],和每列的col[i]。解题报告: 跑一边KM,自带着就把我们需要的期望值给求出来了。AC代码:#include <iostream>#...原创 2018-10-20 11:40:42 · 261 阅读 · 0 评论 -
【UVA - 10891 Game of Sum 】【HRBUST - 1622】 Alice and Bob (区间dp,博弈问题)
题干:有一个长度为N的整数序列,Alice和Bob轮流取数,Alice先取。每次玩家只能从左端或者右端取一个或多个数,但不能两端都取。所有数都被取走后游戏结束,然后统计每个人取走的所有数之和,作为各自的得分。两个人采取的策略都是让自己的得分尽量高,并且两个人都足够聪明。Input输入第一行为组数T(T<=10)。对于每组数据第一行为一个整数N(1<=N<=10...原创 2018-10-13 20:47:27 · 576 阅读 · 0 评论 -
【HDU - 1968】【UVA - 12096】The SetStack Computer (模拟,集合求交集并集操作,STL实现)
题干:Background from Wikipedia: 揝et theory is a branch of mathematics created principally by the German mathematician Georg Cantor at the end of the 19th century. Initially controversial, set theory h...原创 2018-09-06 17:18:15 · 336 阅读 · 0 评论 -
☆【UVA - 624 】CD(dp + 0-1背包 + 记录路径)
题干:You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a tapeNminutes long....原创 2019-10-18 21:21:47 · 177 阅读 · 0 评论 -
【Uva - 10935】 Throwing cards away I (既然是I,看来还有Ⅱ、Ⅲ、Ⅳ?)(站队问题队列问题)
题干: Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operation is performed as long as there are at least two cards in the deck:...原创 2018-08-02 15:10:45 · 232 阅读 · 0 评论 -
【UVA - 10815】 Andy's First Dictionary(STL+字符处理)
题干:Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all t...原创 2018-08-02 15:04:54 · 405 阅读 · 0 评论 -
【POJ - 2349】【UVA - 10369】 Arctic Network(最小生成树求权值第k大的边)(内附两种算法)
题干:The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: ev...原创 2018-07-20 00:10:18 · 389 阅读 · 0 评论 -
【UVA - 10038】Jolly Jumpers (模拟,水题,标记)
题干:题目大意:要任意相邻的两个数的绝对值在[1,n),而且这个范围内的每个数都要出现一次。解题报告: 直接模拟就行了、AC代码:#include<cstdio>#include<iostream>#include<algorithm>#include<queue>#include<map>#inc...原创 2018-12-07 16:27:51 · 327 阅读 · 0 评论