study

Codeforces #527 C

Written by  on March 19, 2015

527C C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular wmm  ×  h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.

[Read more...]

乔姆斯基谱系

Written by  on March 16, 2015

最近一两周编译原理课上面都是讲乔姆斯基谱系,也就是通常所说的0型文法,1型文法,2型文法以及3型文法,课上老师重点讲了2型文法,也就是上下文无关文法,对于其他几种文法提的不多,龙书上面也只讲了上下文无关文法(其他的几种文法提都没有提),课上感觉理解的还是很抽象,所以在这里再好好整理一下网上搜索到的相关概念。

[Read more...]

UVAOJ165

Written by  on March 10, 2015

UVAOJ165 165 – Stamps Time limit: 3.000 seconds  Stamps  The government of Nova Mareterrania requires that various legal documents have stamps attached to them so that the government can derive revenue from them. In terms of recent legislation, each class of document is limited in the number of stamps that may be attached to it. The government wishes to know how many different stamps, and of what values, they need to print to allow the widest choice of values to be made up under these conditions. Stamps are always valued in units of $1.

[Read more...]

UVAOJ301

Written by  on March 4, 2015

UVAOJ301   301 – Transportation Time limit: 3.000 seconds  Transportation  Ruratania is just entering capitalism and is establishing new enterprising activities in many fields including transport. The transportation company TransRuratania is starting a new express train from city A to city B with several stops in the stations on the way. The stations are successively numbered, city A station has number 0, city B station number m. The company runs an experiment in order to improve passenger transportation capacity and thus to increase its earnings. The train has a maximum capacity n passengers. The price of the train ticket is equal to the number of stops (stations) between the starting station and the destination station (including the destination station). Before the train starts its route from the city A, ticket orders are collected from all onroute stations. The ticket order from the station S means all reservations of tickets from S to a fixed destination station. In case the company cannot accept all orders because of the passenger capacity limitations, its rejection policy is that it either completely accept or completely reject single orders from single stations.

[Read more...]

UVAOJ131

Written by  on February 24, 2015

UVAOJ131 131 – The Psychic Poker Player Time limit: 3.000 seconds  The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and have them replaced by the same number of cards from the top of the deck (which is face down). The object is to maximize the value of the final hand. The different values of hands in poker are given at the end of this problem.

[Read more...]

UVAOJ196

Written by  on February 21, 2015

UVAOJ196 196 – Spreadsheet Time limit: 3.000 seconds    Spreadsheet  In 1979, Dan Bricklin and Bob Frankston wrote VisiCalc, the first spreadsheet application. It became a huge success and, at that time, was the killer application for the Apple II computers. Today, spreadsheets are found on most desktop computers.

[Read more...]

UVAOJ705

Written by  on February 13, 2015

UVAOJ705 705 – Slash Maze Time limit: 3.000 seconds   Slash Maze  By filling a rectangle with slashes (/) and backslashes ( ), you can generate nice little mazes. Here is an example:

[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...]