![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
UVA
LazyYangHuan
此人很懒,什么题目都写。
展开
-
UVA 12563 《劲歌金曲》
UVA 12563 Jin Ge Jin Qu hao(01背包变形:两个条件最优化)这道题是背包问题变形,主要注意两点:这题,要求歌曲数目尽量多,其次再考虑歌曲时长。就是说两个状态,状态1:数目多,时间少;状态2:数目少,时间多。依据题意,我们要选择状态一。 当两状态数目相同时,我们要选择时间长的那个状态。#include <cstdio>#include <c...原创 2018-10-17 19:10:39 · 263 阅读 · 0 评论 -
UVA 10305 - Ordering Tasks
经典拓扑排序题目;TopSort 思路:https://blog.csdn.net/qq_34022601/article/details/84303726#include <cstdio>#include <algorithm>#include <map>#include <cstring>#include <vector&...原创 2018-11-20 23:42:38 · 114 阅读 · 0 评论 -
UVA 572 - Oil Deposits
这道题是一道八连通图的问题。貌似POJ上也有一题类似的。思路蛮简单的,就是图的BFS遍历的算法。要遍历图的每一个顶点才行。但是,我在BFS时把 ‘@’ 置换为‘*’,这样我就不会再一次遍历到同一块油田了。#include <cstdio>#include <queue>using namespace std;char s[102][102];//位向量 ...原创 2018-11-15 23:24:32 · 142 阅读 · 0 评论 -
UVA 1600 - Patrol Robot
这题是一道简单的BFS,原本没有AC是以为不能走重复的路。后来发现这不是一道普通的BFS,也就是说,我可以往回走(走已经走过的结点),找到更优的解决方案.所以我们要设置一个记录障碍信息的数组(且称为bar),这个数组记录了当前节点已经走过的障碍数.(0,1,2,...,k)。1.如果已经连续穿越了K的障碍,下一个他只能走到不是障碍(maze[x][y]==0)的地方。2.如果BFS过程中,...原创 2018-11-11 15:25:05 · 139 阅读 · 0 评论 -
UVA 536 - Tree Recovery
二叉树 先序遍历和中序遍历获得后序遍历Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example...原创 2018-11-03 00:26:34 · 184 阅读 · 0 评论 -
UVA 548-Tree
递归建树问题You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf. The value of a path is t...原创 2018-11-02 23:49:07 · 140 阅读 · 0 评论 -
UVA 839 & UVA699
二叉树DFS1.递归建树+在树上递归计算答案 8392.直接递归计算答案 699UVA 839这题注意一下输出格式就好了#include<cstdio>#include<cstdlib>using namespace std;struct Node{ int w,d; Node *right,*left;};Node *newnode(v...原创 2018-11-04 17:04:17 · 125 阅读 · 0 评论 -
UVA 439 - Knight Moves
#include <cstdio>#include <algorithm>#include <queue>#include <cstring>using namespace std;int dis[10][10];int dx[5]={-2,-1,1,2};int dy[5][2]={-1,1,-2,2,-2,2,-1,1};...原创 2018-11-04 16:51:09 · 149 阅读 · 0 评论 -
UVA 712 S-Trees
#include <cstdio>#include <cstring>using namespace std;int main(){ int n,t,Case=1,num; while ( scanf ("%d",&n)&&n) { int k=0; num= 2<<(n-1) ; char leaf[260]...原创 2018-11-03 21:00:30 · 98 阅读 · 0 评论 -
UVA 673 - Parentheses Balance
You are given a string consisting of parentheses () and []. A string of this type is said to be correct:if it is the empty string if A and B are correct, AB is correct, if A is correct, (A) and [A...原创 2018-11-03 15:40:12 · 142 阅读 · 0 评论 -
UVA 122 Trees on the level
Trees are fundamental in many branches of computer science (Pun definitely intended). Current state- of-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and oc...原创 2018-10-29 19:44:16 · 154 阅读 · 0 评论 -
UVA 11729 突击战
这是一个排序问题,要根据执行时间从到小排序。执行时间越长,在执行时间内我能分配,执行更多任务。 执行时间相同时,最短与交代任务的时间长短排序方式无关。例如34 53 52 5这三组数据任意排序,最短时间始终是14代码如下#include <cstdio>#include <algorithm>using namespace std;s...原创 2018-10-21 14:32:36 · 143 阅读 · 0 评论 -
UVA 11292 勇者斗恶龙
水题一个,两个排序解决问题#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(){ int n,m,sum; int head[20005]={0}; int loo[20005]={0}; while (~scanf ("...原创 2018-10-21 13:41:23 · 132 阅读 · 0 评论 -
UVA 10048 - Audiophobia
题目大意:C个点,S条边,Q个询问,存在多组数据输入。无向图边权非负,问两点间路径中边权最大值集合中,输出最大值最小的那条路径的最大值。解题思路:1.Floyd的变形:如果我们把Floyd算法 变形如下:i-->k,k-->j 的路径最大值和当前i-->j的路径最大值比较,我们选取最大值小的哪一个,Floyd仍然成立。 ...原创 2018-12-01 10:02:34 · 211 阅读 · 0 评论