uvaoj

UVAOJ839

Written by  on February 12, 2015

UVAOJ839 不需要建树,直接遍历,如果平衡就返回正常值,否则返回0. Shell

[Read more...]

UVAOJ327

Written by  on February 8, 2015

UVAOJ327 327 – Evaluating Simple C Expressions Time limit: 3.000 seconds  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 more than 110 characters. The expressions to be evaluated will contain only simple integer variables and a limited set of operators; there will be no constants in the expressions. There are 26 variables which may appear in our simple expressions, namely those with the names a through z(lower-case letters only). At the beginning of evaluation of each expression, these 26 variables will have the integer values 1 through 26, respectively (that is, a = 1, b = 2, …, n = 14, o = 15, …,z = 26). Each variable will appear at most once in an expression, and many variables may not be used at all.

[Read more...]

UVAOJ699

Written by  on February 5, 2015

UVAOJ699 699 – The Falling Leaves Time limit: 3.000 seconds   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 the trees. If the same thing happened to binary trees, how large would the piles of leaves become?

[Read more...]

UVAOJ712

Written by  on February 3, 2015

UVAOJ712 712 – S-Trees Time limit: 3.000 seconds   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. Each of the S-tree’s nodes has a depth, which is the amount of nodes between itself and the root (so the root has depth 0). The nodes with depth less than n are callednon-terminal nodes. All non-terminal nodes have two children: the right child and the left child. Each non-terminal node is marked with some variable xi from the variable set Xn. All non-terminal nodes with the same depth are marked with the same variable, and non-terminal nodes with different depth are marked with different variables. So, there is a unique variable xi1 corresponding to the root, a unique variable xi2 corresponding to the nodes with depth 1, and so on. The sequence of the variables is called the variable ordering. The nodes having depth n are called terminal nodes. They have no children and are marked with either 0 or 1. Note that the variable ordering and the distribution of 0’s and 1’s on terminal nodes are sufficient to completely describe an S-tree.

[Read more...]

UVAOJ297

Written by  on January 29, 2015

UVAOJ297 297 – Quadtrees Time limit: 3.000 seconds  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 be split in four sub quadrants, etc. In the quadtree, the image is represented by a parent node, while the four quadrants are represented by four child nodes, in a predetermined order.

[Read more...]

UVAOJ548

Written by  on January 3, 2015

UVAOJ548 548 – Tree Time limit: 3.000 seconds   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 the sum of values of nodes along that path.

[Read more...]

UVAOJ112

Written by  on January 3, 2015

UVAOJ112 112 – Tree Summing Time limit: 3.000 seconds  Tree Summing  Background LISP 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 LISP, can easily be adapted to represent other important data structures such as trees.

[Read more...]

AOAPC I: Volume 2.Data Structures-Lists

Written by  on December 27, 2014

<<算法竞赛入门经典>> UVaoj第三卷数据结构链表习题: 127-“Accordian” Patience UVAOJ127 101-The Blocks Problem UVAOJ101

[Read more...]

UVAOJ11234

Written by  on December 26, 2014

UVAOJ11234||POJ3367 Expressions Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2591 Accepted: 850 Description Arithmetic 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 expression in infix notation. However, it is easier to write a program to evaluate an expression if the expression is written in postfix notation (also known as reverse Polish notation). In postfix notation, an operator is written behind its two operands, which may be expressions themselves. For example, x y + z w – * is a postfix notation of the arithmetic expression given above. Note that in this case parentheses are not required.

[Read more...]

UVAOJ11111

Written by  on December 26, 2014

UVAOJ || POJ3195 Generalized Matrioshkas Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1835 Accepted: 538 Description Vladimir worked for years making matrioshkas, those nesting dolls that certainly represent truly Russian craft. A matrioshka is a doll that may be opened in two halves, so that one finds another doll inside. Then this doll may be opened to find another one inside it. This can be repeated several times, till a final doll – that cannot be opened – is reached.

[Read more...]