csdn编程挑战7月

第五届在线编程大赛月赛指定题目:反向互补子串

这是个字符串问题。我们的字符串只包含大写字母。我们定义一个字母和它13位以后的字母互补。即A与N互补,B与O互补,C与P互补……,我们需要找一个字符串的两个不重叠的子串,其中一个和另外一个的翻转全互补。另外,因为我们的问题来自生物学,所以我们允许这两个字符串的一个可以删掉两个字符(注意:仅允许一个字符串删掉任意位置的两个字符,另外一个必须全部互补上)。我们的目的是求最长的反向互补子串的长度。

输入格式:

多组数据,每组数据一行,有一个字符串。每个字符串长度不超过2000,只有大写英文字母组成。

输出格式:

每组数据输出一行包含一个整数,表示最长的反向互补子串长度。

答题说明


输入样例

ABCD

ABCDQOPN

ABON

输出样例:

0

2

2

解释:

第一个样例,没有互补的子串。

第二个样例,AB和NO互补,所以反向互补子串的时候我们可以选择NPO,删掉一个P即可。

第三个样例,AB与ON反向互补。

=============================================================

微软Azure•英雄会第五届在线编程大赛月赛第四题:Core allocation

题目详情

There are M machines, in which the i-th machine has Ci cores (i starts from 1). On each machine, cores are structured in a line.

There are Q queries of the following types to serve:

    1. Ask for k cores. We have to find the first machine (with the

least index) such that it has k free continuous cores and allocate them

to customer. If there is a solution, return the result (m, c), in which m

is the index of machine and c is the index of the first core allocated

on the machine. Otherwise, return (-1,-1). Once the cores are allocated,

they cannot be used until they are freed.

     2. Free the cores

allocated in the a-th query of the first type. We guarantee that the

a-th query of the first type exists and each query is freed at most

once. If the corresponding query didn't have a solution, you should just

ignore it.

[Input Specification]

First a line gives an integer T, the number of test cases.

For

each test case, the first line gives M and Q, then M lines follow, each

of which contains one number, indicating Ci for the i-th line. For the

next Q lines, each of them gives a query.

     1. A k. Corresponds to the first type of query, k is the number of requested cores.

     2. F a. Corresponds to the second type of query, a indicates the a-th query of the first type.

All numbers are integers.

[Output Specification]

For

each test case, first output a line in this format "Case #i:" ( without

quote), in which i is the case number, starting from 1. After that,

output result for each query of type 1, either "m c" (without quote) if

there is solution to the query, or "-1 -1" (without quote) if no

solution found.

[Restrictions]

1 <= T <= 20

1 <= M <= 100000

1 <= Ci <= 128

1 <= Q <= 1000000

1 <= k <= 128

1 <= a <= Q

The number of queries of type 1 is the same as that of type 2.

答题说明

[Sample Input]

2

3 10

1

1

1

A 1

A 1

A 1

A 1

F 2

A 1

F 5

F 4

F 3

F 1

3 16

1

2

3

A 2

A 2

A 1

F 2

A 4

F 4

A 3

F 1

A 1

F 5

A 2

A 1

F 7

F 8

F 3

F 6

[Sample Output]

Case #1:

1 1

2 1

3 1

-1 -1

2 1

Case #2:

2 1

3 1

1 1

-1 -1

3 1

2 1

3 1

2 2

=============================================================

第五届在线编程大赛月赛第三题:石子游戏(1)

题目详情

甲乙两人面对若干堆石子,其中每一堆石子的数目可以任意确定。

两人轮流按下列规则取走一些石子,游戏的规则如下:

1.每一步应取走至少一枚石子;

2.每一步只能从某一堆中取走部分或全部石子;

3.如果谁无法按规则取子,谁就是输家。

如果甲乙两人都采取最优的策略,甲先拿,请问,是甲必胜还是乙必胜.

输入格式:

多组数据,每组数据两行,第一行是一个整数N, 2<=N<=10000

下一行是N个正整数,代表每堆的石子数,石子数在32位整数内。

输出格式:

每组测试数据输出一行,如果甲存在必胜策略,输出"Win",否则输出"Lost"

答题说明

输入样例

3

3 3 1

输出样例:

Win


你可能感兴趣的:(编程挑战)