| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11437 | string exam |
|
| 11462 | cppreference |
|
| 11465 | Use std::map |
|
| 11492 | rotate |
|
| 11494 | Set operations |
|
| 11787 | The Blocks Problem |
|
Description
Write a program that will reverse the order of words in each sequence of sentences while preserve the order of letters.
Input
The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by a white space.
Output
The output will consist of the same lines and words as the input file. However, the order of words will be reversed.
Sample Input Download
Sample Output Download
Partial Judge Code
11437.cppPartial Judge Header
11437.hTags
Discuss
Description
This is an advanced version of http://acm.cs.nthu.edu.tw/problem/11447/
Notice, this time, first and last is [first, last].
Hint: std::map<std::string,...>
lower_bound and upper_bound can help you.
Input
The input consist of series of command. Each commands is insert, sum, range output, range erase or output.
insert: inserts a integer (0<=val<65536) with a string (key) to map. If the key has already existed, insert the val at the begining of integer (the val which the key belongs).
For example,
insert a 10
insert b 20
The map should contain 10, 20.
insert a 20
The map should contain 20 10, 20.
sum: sums up the integer with the key. Sum is 0 if a key is not existed. Output a newline character ('\n') after printing the sum.
For example,
insert a 10
insert b 20
The map should contain 10, 20.
insert a 20
The map should contain 20 10, 20.
sum a
It should output 30 (because 20 + 10).
range output: outputs the integer from key (first) to key (last). Output a space character (' ') after printing an element. Output a newline character ('\n') after printing all elements (even first key equals to last key).
For example,
insert a 10
insert b 20
The map should contain 10, 20.
insert a 20
The map should contain 20 10, 20.
range output a b
It should output 2010 20.
range erase: erase the integer from key (first) to key (last).
output: outputs all integer in map. From the smallest key to biggest key. Output a space character (' ') after printing an element. Output a newline character ('\n') after printing all elements (even map is empty).
insert a 10
insert b 20
The map should contain 10, 20.
insert a 20
The map should contain 20 10, 20.
output
It should output 2010 20.
Output
Complete the above operations.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given an integer sequence, say {0, 1, 2, 3, 4, 5}, we can rotate the sequence to right 1 time and generate a new sequence.
Try to generate all possible results for the original sequence, and print the result by the order they show up.
For the example above, the output would be :
5 0 1 2 3 4
4 5 0 1 2 3
3 4 5 0 1 2
2 3 4 5 0 1
1 2 3 4 5 0
0 1 2 3 4 5 (loop occuring, stop output result from this on.)
Input
An integer sequence, separated by spaces. End by EOF.
Output
List all possible unique results generated from original sequence by rotation and output them by the order they show up .
Each line contains one sequence, where there is a space between each number.
Note that there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
假設有A B C 3個set,range_diff A C的結果是
- A與B做difference,得到D
- 將D與C做difference,得到range_diff A C的結果
lower_bound and upper_bound can help you.
Input
How to compare the integer sequence (calculate the key of an integer sequence):
- key=sum every elements in an integer sequence
- if the length of a integer sequence is 0, the key is 0.
- e.g., the key of an integer sequence "3 9 -1 3 -6" is 8 (3+9-1+3-6).
The input consist of series of command. Each commands is insert, range_diff, range_inter or range_out.
insert: inserts an integer sequence (each value is greater than -11 and smaller than 11, stop reading from cin when value is 0). If a key has already existed, then replace it with the input sequence.
For example,
insert 3 9 -1 3 -6 0
The set should contain 3 9 -1 3 -6.
insert 2 2 -3 7 0
The set should contain 2 2 -3 7.
range_diff: calculates difference of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the difference. Note: What is the difference between set_difference and set_symmetric_difference? Warning: You must calculate from smaller key to bigger key.

For example,
insert 2 -5 -5 0
insert 3 -5 -5 -5 2 10 0
insert 2 10 3 -5 0
range_diff -8 9
It should output
-5 3 10
For example,
insert 2 -5 -5 0
insert 3 -5 -5 -5 2 10 0
insert 2 10 3 -5 0
range_diff -8 16
It should output
2
For example,
insert 2 -5 -5 0
insert 3 -5 -5 -5 2 10 0
insert 2 10 3 -5 0
range_diff -5 16
It should output
-5 -5
range_inter: calculates intersection of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the intersection.

For example,
insert 2 -5 -5 0
insert 3 -5 -5 -5 2 10 0
insert 2 10 3 -5 0
range_inter -8 16
It should output
-5 2
range_out: outputs all integer sequences from an integer (first key) to an integer (second key). Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing all elements of a key. Do not print anything if first key equals to second key.
For example,
insert 2 -5 -5 0
insert 3 9 -1 3 -6 0
insert 7 6 1 2 0
range_out -7 12
It should output
3 9 -1 3 -6
Output
Complete insert, range_diff, range_inter and range_out.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in which a robot arm performed tasks involving the manipulation of blocks.
In this problem you will model a simple block world under certain rules and constraints. Rather than determine how to achieve a specified state, you will “program” a robotic arm to respond to a limited set of commands.
The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are n blocks on the table (numbered from 0 to n − 1) with block bi adjacent to block bi+1 for all 0 ≤ i < n − 1 as shown in the diagram below:

The valid commands for the robot arm that manipulates blocks are:
- move a onto b
where a and b are block numbers, puts block a onto block b after returning any blocks that are stacked on top of blocks a
and b to their initial positions.
- move a over b
where a and b are block numbers, puts block a onto the top of the stack containing block b, after returning any blocks that
are stacked on top of block a to their initial positions.
- pile a onto b
where a and b are block numbers, moves the pile of blocks consisting of block a, and any blocks that are stacked above
block a, onto block b. All blocks on top of block b are moved to their initial positions prior to the pile taking place. The blocks
stacked above block a retain their order when moved.
- pile a over b
where a and b are block numbers, puts the pile of blocks consisting of block a, and any blocks that are stacked above block
a, onto the top of the stack containing block b. The blocks stacked above block a retain their original order when moved.
- quit
terminates manipulations in the block world.
Any command in which a = b or in which a and b are in the same stack of blocks is an illegal command. All illegal commands should be ignored and should have no affect on the configuration of blocks.
(This problem is provided by UVA.)
hint: 每個位置(stack)上,若有block在上面的話,則最底下的block編號一定跟位置是一樣的(例如,若第9個stack上面有block,則那一疊的block最下面一定是編號9),所以歸還block到原本的位置這個動作沒有想像中複雜
Input
The input begins with an integer n on a line by itself representing the number of blocks in the block world. You may assume that 0 < n < 25.
The number of blocks is followed by a sequence of block commands, one command per line. Your program should process all commands until the quit command is encountered.
You may assume that all commands will be of the form specified above. There will be no syntactically incorrect commands.
Output
The output should consist of the final state of the blocks world. Each original block position numbered i (0 ≤ i < n where n is the number of blocks) should appear followed immediately by a colon. If there is at least a block on it, the colon must be followed by one space, followed by a list of blocks that appear stacked in that position with each block number separated from other block numbers by a space. Don’t put any trailing spaces on a line.
There should be one line of output for each block position (i.e., n lines of output where n is the integer on the first line of input).