uvaoj
文章平均质量分 75
nianiajr
http://www.liangjiarui.com/
展开
-
uva489-Hangman Judge
In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic game原创 2013-02-27 12:33:48 · 519 阅读 · 0 评论 -
uva297-四叉树
Quadtrees A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again原创 2013-07-29 00:56:22 · 963 阅读 · 0 评论 -
uva 639
D - Don't Get RookedTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusAppoint description: System Crawler (2013-05-30)Description原创 2013-08-06 17:18:50 · 700 阅读 · 0 评论 -
uva 539
E - The Settlers of CatanTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusAppoint description: System Crawler (2013-05-30)Description原创 2013-08-06 17:23:01 · 714 阅读 · 0 评论 -
uva 331
F - Mapping the SwapsTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusAppoint description: System Crawler (2013-05-30)Description原创 2013-08-06 17:30:56 · 693 阅读 · 0 评论 -
uva 11995
这个题其实就是掌握基础栈,队列,与优先队列基础操作的,将他们模仿一遍判断下就好,注意的是有个小坑,如果入的次数小于出的操作那明显是不可能的,要输出Impossible// UVa11992 Fast Matrix Operations(更易读、更具一般性的版本)// Rujia Liu// 注意:所有叶子上总是保留set标记而不会被清除(pushdown只能针对非叶结点),因此mainta原创 2013-08-21 11:53:01 · 774 阅读 · 0 评论 -
uva 11991
这个题是学会使用stl中的map映像来进行匹配,相比单用纯数组要方便多了,熟练运用将会方便很多。此题只需要用map >创建一个动态匹配,每一个key就是一个动态数组,以此来储存各个相同key的下标。#include#include#include#includeusing namespace std;map > m;int main(){ int n,q,a,k,v原创 2013-08-21 12:24:58 · 760 阅读 · 0 评论 -
uva 1203
这个题目大概意思是有一种触发器一样的东西,每次输入以后就算是激活了,每个响应周期就要返回这个数字,当有多个数字要在同一时间返回时,那就要输出最小的数字,那么其实每次都是取最优的问题,由于这些数据成一种线性排布,那么最优的话就应该想到可以用优先队列来维护这些数据,这也是题目的考查意向,那就是熟悉优先队列,具体的就看代码了,一定要学会优先队列的优先重载运算定义:#include#include原创 2013-08-21 21:47:23 · 738 阅读 · 0 评论 -
uva 11997
这是从刘汝佳训练指南上找的例题,值得学习的地方就是要养成把问题拆分然后再多路归并的好习惯,题目是要求从k组数据中任意取一个数找出然后选出其中和最小的k组数据,选择最小可以用优先队列很快实现,那么如何选择就应该想想选择呢?按书上思路就是先把问题分成只有两组数据时的情况,那么列式就变成:A1+B1A2+B1.AN+B1那么这样以来我们每次选出最优的就可以了,然后把其去掉再比较再选择原创 2013-08-22 13:41:43 · 814 阅读 · 0 评论 -
uva 1160
此题意思大概就是使得给出化合物来装运,但得保证n个化合物中刚好有n种元素,那么我们以每个元素为一个结点,装上车化合物即会连边成图,这样以来就能想到为避免爆炸就不应该出现环的情况,因为在无环图中,n个点也就只有n-1条边,每条边代表一个化合物,那么有环的时候就刚好是n个点n个化合物了,这便是把实际问题抽象出图论模型,这样以来问题就变成检验是否有环和无环的问题了。对于检验是否存在环,笨一点的办法就原创 2013-08-22 15:54:34 · 668 阅读 · 0 评论 -
uva 1329
这个题大概意思就是描述子节点到根节点距离关系,但随着I的操作,每次根节点可能会改变,可以先把问题这么想,距离既然只是节点到根节点的关系,那么进行状态压缩是必要的,因为节点是如何到根节点的我们并不关心,但要是根节点也改变了,那么我们得在更新该节点到新根节点的距离前,把该节点的父亲节点到新根节点的距离给维护了,这就是为什么的先维护父亲节点,再来更新,否则会报错,一定要分清他们的先后顺序,否则会WA。原创 2013-08-22 18:33:38 · 748 阅读 · 0 评论 -
uva 1428
题意:给出n个乒乓球选手的能力值a[i],要求从其中选出三个人,一个为裁判,两个作为选手,且裁判的能力位于两者之间,位置也位于两者之间,问有多少种方法,类似这样的题,要抽象成数学模型那就应该确定其中一个的位置来找其他两个的数学关系,不妨我们先确定裁判的位置,假设裁判位置为i,那么就得从1~i-1和i+1~n中选两个能力值分别位于裁判两边的选手,那么在1~i-1中假设有c[i](i表示裁判位置)个选原创 2013-08-23 18:24:44 · 786 阅读 · 0 评论 -
uva 1428 ---RMQ应用
这是今天学会的内容,RMQ一般用来查询连续区间的信息的比如最大值最小值之类的,巧妙一点的就像本题经过一点转化将统计一个非降序序列的相同子串的最大长度,不过运用RMQ一定要熟练掌握它的预处理以及查询,记熟模版才是关键,看来是有必要每次做题就用个小本记录一下代码。#include#include#include#includeusing namespace std;const int原创 2013-08-26 23:40:39 · 592 阅读 · 0 评论 -
uva 10905 Children's Games
这个题的意思是给你n个数字字符串,要求你把他们拼接组成字典序最大的一个串输出,那么很明显这是一个基础的贪心,通过将两个字符串a,b拼接,有两种情况:a+b或者b+a,把字典序变大的先排在前面,以这样的规则进行排序,最后按顺序输出就好了。#include#include#includeint cmp(const void*_a,const void*_b){ char* a = (原创 2013-08-15 15:54:34 · 628 阅读 · 0 评论 -
uva 10763 Foreign Exchange
这个题大概意思是有n个学生进行交换,要从a到b,但前提是b有要去a的,就是让你判断这次交换是否能行,那么我们可以这么想,就算没有从b去a的,但有从c想去a的,a刚好有人去c那么c可以先去b再去a,这样的策略同样是可行的,那么这样一来问题就简单了,只需要考虑每个地方来的人和走的人相等就好。#include#include#includestruct exchange{ int a;原创 2013-08-15 16:02:15 · 689 阅读 · 0 评论 -
uva 10132 File Fragmentation
这个题挺恶心,弄了不少时间,大概意思是有2n个文件碎片,他们都是从原来的一模一样的n个文件拆成两半形成的,要你根据这些碎片确定原来文件,一开始就应该能想到要把这些碎片长度从小到大排个序,然后我就天真的以为最短+最长的应该就是了,确实没错,但这里有个问题就是如果最短和最长的文件都有多个,那么问题就出来了,这里就必须得用枚举,来确定原文件碎片,不过这个题目数据有点水,只要把文件长度排序后,找到最长和最原创 2013-08-15 16:10:40 · 727 阅读 · 0 评论 -
uva 1400 动态连续最大和
题目大意就是求给出n个数的排列,求其中连续的最大和,由于会有n多的查询,查询是任意的,那么就是动态的查询,RMQ解决不了这样的问题,用线段树可以实现动态查询,还好本题没要更新,不过光记录的信息就会有很多,思路是根据训练指南上面给的思路,构造一棵线段树,其中每个结点维护3个值:max_sub(a,b),max_prefix(a,b),max_suffix(a,b),然后通过区间合并维护建树,最后在已原创 2013-08-27 16:31:00 · 660 阅读 · 0 评论 -
uva112
BackgroundLISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the oldest languages currently being used. Lists, which are the fundamental data structures in LI原创 2013-07-27 17:13:01 · 843 阅读 · 0 评论 -
uva11111--栈的应用
Problem B - Generalized Matrioshkas Vladimir worked for years making matrioshkas, those nesting dolls that certainly represent truly Russian craft. A matrioshka is a doll that may be opene原创 2013-07-26 16:07:52 · 988 阅读 · 0 评论 -
uva 327--Evaluating Simple C Expressions
The task in this problem is to evaluate a sequence of simple C expressions, buy you need not know C to solve the problem! Each of the expressions will appear on a line by itself and will contain no mo原创 2013-07-30 19:14:15 · 781 阅读 · 0 评论 -
uva 712-S-Trees
S-Trees A Strange Tree (S-tree) over the variable set is a binary tree representing a Boolean function . Each path of the S-tree begins at the root node and consists of n+1 nodes. Eac原创 2013-07-30 12:29:04 · 879 阅读 · 0 评论 -
uva-The falling leaves
The Falling Leaves Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under原创 2013-07-30 15:01:45 · 932 阅读 · 0 评论 -
uva572 - Oil Deposits
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th原创 2013-07-31 13:48:35 · 626 阅读 · 0 评论 -
uva442-矩阵链乘
Your job is to write a program that determines the number of elementary multiplications needed for a given evaluation strategy.Input SpecificationInput consists of two parts: a list of matrices原创 2013-07-24 16:56:44 · 2407 阅读 · 0 评论 -
uva127-模拟纸牌游戏
You are to simulate the playing of games of ``Accordian'' patience, the rules for which are as follows:Deal cards one by one in a row from left to right, not overlapping. Whenever the card matches原创 2013-07-24 23:17:17 · 1461 阅读 · 0 评论 -
uva 439 - Knight Moves
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboa原创 2013-07-31 16:18:26 · 590 阅读 · 0 评论 -
uva 839 - Not so Mobile
Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small原创 2013-07-30 23:21:27 · 717 阅读 · 0 评论 -
uva 10562 - Undraw the Trees
Professor Homer has been reported missing. We suspect that his recent research works might have had something to with this. But we really don't know much about what he was working on! The detectives t原创 2013-07-31 13:27:14 · 580 阅读 · 0 评论 -
uva 10305 - Ordering Tasks
John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed.InputThe input will consist of several原创 2013-07-31 21:01:37 · 770 阅读 · 0 评论 -
uva 10004 - Bicoloring
In 1976 the ``Four Color Map Theorem" was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that no region is colored us原创 2013-08-01 13:55:16 · 723 阅读 · 0 评论 -
uva11234-
Problem E: ExpressionsArithmetic expressions are usually written with the operators in between the two operands (which is called infix notation). For example, (x+y)*(z-w) is an arithmetic expressi原创 2013-07-25 13:44:46 · 1007 阅读 · 0 评论 -
uva 10596 - Morning Walk
Kamal is a Motashota guy. He has got a new job in Chittagong. So, he has moved to Chittagong from Dinajpur. He was getting fatter in Dinajpur as he had no work in his hand there. So, moving to Chittag原创 2013-08-01 16:18:42 · 646 阅读 · 0 评论 -
uva 532 - Dungeon Master
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south原创 2013-08-01 21:48:41 · 649 阅读 · 0 评论 -
uva 784 - Maze Exploration
A maze of rectangular rooms is represented on a two dimensional grid as illustrated in figure 1a. Each point of the grid is represented by a character. The points of room walls are marked by the same原创 2013-08-02 00:47:50 · 655 阅读 · 0 评论 -
uva 11988
这其实是一道很简单的模拟题,方法都相近,可能用数学的思维解比较巧妙,不过直白点就用链表模拟,可是由于最近没怎么做题了,一直WA,傻逼的没发现很白的错误,诶,看来做什么都是要持之以恒的,如果只是三天打鱼两天晒网,是根本不可能有什么太大收获,一定要好好做题了。#include#include#include using namespace std;struct list{ c原创 2013-09-06 22:25:40 · 817 阅读 · 0 评论