`
yuanlanxiaup
  • 浏览: 857875 次
文章分类
社区版块
存档分类
最新评论

2010年东北大学ACM程序设计竞赛冬季校赛题解

 
阅读更多

8题只做出4题比较easy的题,而且做得挺麻烦,看来还要多练练。

AC的题如下

NEUOJ 1112I Love Apple

Description
So many people love apple and there is a problem about apple.

An Apple Word is a word that consists of only the letters A, P, L, and E, in that exact relative order. There must be exactly one A, two or more Ps, exactly one L and exactly one E. Case does not matter.

For example, "Apple" and "apPpPPlE" are Apple Words, while "APLE", "Apples", "Aplpe" and "coconut" are not. You are given a string word which you must turn into an Apple Word. For each character in word, you can either replace it with a different letter or leave it unchanged. No other operations, like inserting new characters or deleting existing characters, are allowed.

Please find the minimal number of characters you must replace to get an Apple Word. If it's impossible, output -1.
Input
There're multiple test cases.
Each case is a string contain between 1 and 50 characters, inclusive.
Each character in input string will be an uppercase letter ('A'-'Z') or a lowercase letter ('a'-'z').
Output
For each case, output the minimal number of characters you must replace to get an Apple Word, If it's impossible, output -1
Sample Input
apPpPPlE
APLE
NEUAcmer
Sample Output
0
-1
8
Hint
Source
2010年东北大学ACM程序设计竞赛冬季校赛
Problem 1114 - A Easy Problem
Description
Risk is a board game played on a world map. This world is divided into regions by borders.
Each region is controlled by a player (either you or one of your opponents). Any region that
you control contains a positive number of your armies.
In each turn, you are allowed to move your armies. Each of your armies may either stay
where it is, or move from a region to a bordering region under your control. The movements
are performed one by one, in an order of your choice. At all times, each region must contain
at least one army.
For strategic purposes, it is important to move your armies to regions that border your
opponents’ regions and minimize the number of armies on your regions that are totally surrounded
by other regions under your control. You want your weakest link, i.e., the border
region with the minimum number of armies, to be as strong as possible. What is the maximum
number of armies that can be placed on it after one turn?
Input
On the first line a positive integer: the number of test cases, at most 100. After that per test
case:
One line with an integer n (1 <= n <= 100): the number of regions.
One line with n integers ai (0 <= ai <= 100): the number of your armies on each region.
A number 0 indicates that a region is controlled by your opponents, while a positive
number indicates that it is under your control.
n lines with n characters, where each character is either ‘Y’ or ‘N’. The i-th character
of the j-th line is ‘Y’ if regions i and j border, and ‘N’ otherwise. This relationship is
symmetric and the i-th character of the i-th line will always be ‘N’.
In every test case, you control at least one region, and your opponents control at least
one region. Furthermore, at least one of your regions borders at least one of your opponents’
regions.
Output
Per test case:
One line with an integer: the maximum number of armies on your weakest border
region after one turn of moving.
Sample Input
2
3
1 1 0
NYN
YNY
NYN
7
7 3 3 2 0 0 5
NYNNNNN
YNYYNNN
NYNYYNN
NYYNYNN
NNYYNNN
NNNNNNY
NNNNNYN
Sample Output
1
4
Hint
Source
2010年东北大学ACM程序设计竞赛冬季校赛
Problem 1116 - Double Xor
Description
once upon a time, there is a very strange computer. Its memory consists of several bits, each initially set to 0, and it can only perform the following type of operation:

Choose one of the bits in memory, and choose a value - 0 or 1. All the bits between the selected bit and the last bit in memory, inclusive, will be set to the chosen value.

For example, if the memory is "0010", and you choose the second bit and a value of 1, the memory will change to "0111". You are given a string mem.

The number of characters in mem is equal to the number of bits in the computer's memory. Compute the minimum number of operations required to set the computer's memory equal to mem.
Input
There're multiple test cases.
Each case contain a string which is mem. It will contain only the characters '0' (zero) or '1' (one) and between 1 and 50 characters, inclusive.
Output
For each test cases only a integer indicate the minimum times of operations required to set the computer's memory equal to mem.
Sample Input
0100
111000111
Sample Output
2
3
Hint
Source
2010年东北大学ACM程序设计竞赛冬季校赛
Problem 1117 - Strange Computer
Description
once upon a time, there is a very strange computer. Its memory consists of several bits, each initially set to 0, and it can only perform the following type of operation:

Choose one of the bits in memory, and choose a value - 0 or 1. All the bits between the selected bit and the last bit in memory, inclusive, will be set to the chosen value.

For example, if the memory is "0010", and you choose the second bit and a value of 1, the memory will change to "0111". You are given a string mem.

The number of characters in mem is equal to the number of bits in the computer's mem ory. Compute the minimum number of operations required to set the computer's memory equal to mem.
Input
There're multiple test cases.
Each case contain a string which is mem. It will contain only the characters '0' (zero) or '1' (one) and between 1 and 50 characters, inclusive.
Output
For each test cases only a integer indicate the minimum times of operations required to set the computer's memory equal to mem.
Sample Input
0100
111000111
Sample Output
2
3
Hint
Source
2010年东北大学ACM程序设计竞赛冬季校赛

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics