河南省第十二届ACM大学生程序设计竞赛试题

A  DNA序列---复制问题                   Time Limit: 1000MS

核酸与蛋白质是生物体内两大重要的生物大分子,其中核酸是生物遗传信息从上一代传到下一代的的重要载体。核酸的基本组成单元是核苷酸,可将核苷酸分为脱氧核苷酸(DNA)和核糖核苷酸(RNA)。

我们以DNA为例,所有的DNA核苷酸的磷酸基团和糖基团都是一样的,但其化学组成的碱基基团有四种类型,腺嘌呤(A)、鸟嘌呤(G)、胞嘧啶(C)、胸腺嘧啶(T)。因此,对DNA序列的单链研究可以转化为研究由AGCT四个字母组成的字符串。

DNA复制是指以原始的DNA分子为模板合成出相同分子的过程。在一些酶的作用下,DNA复制过程的有四种可能:完全复制、半保留复制、逆复制、逆半保留复制。

给定一个带有遗传信息的模板mode,你能在DNA序列s中找到这样的复制过程最多有多少次?

【标准输入】

第一行:     T        表示以下有T组测试数据              1 ≤ T ≤ 8

每组数据, 占一行:

mode  s        (|mode |≤ 20,    |s| ≤ 300 , mode与s之间至少一个空格)

【标准输出】

对每组测试数据,输出占一行,

【 样  例 】

标准输入

标准输出

2

ACGA  AGACGACGAGCAGCAACGA

AAA   ACGATTAAAAAGTCTAAAA                     

5

5

  说明:

1 半保留复制是指本次复制可以与前次复制部分重叠。例如:ACGACGA,2次复制。类似逆半保留

复制,例如:AGCAGCA,2次复制。

2 若模板是回文串,逆复制过程不再统计。

  

 

 

B  DNA序列---同源问题                    Time Limit: 1000MS

从本质上看,DNA序列不是一条条孤立的序列。每条序列都是通过进化遗传规律从远古的祖先序列演化而来的。在生物学上,如果两条DNA序列是从一个公共祖先序列进化而来的,则称二者具有同源性。

判断两条DNA序列是否同源的一个主要依据是探寻它们之间的相似性。序列重排和对齐是比较两条DNA序列相似程度的做法。为此,需要对它们各个位点的残基进行对齐,然后考虑从其中一条序列出发经过“变异操作“能否将其演变为另一条序列。其中“变异操作”包括:

  1. 替换:在某个点位从一种残基替换为另一种残基;
  2. 增加:在一条序列中新增加了残基;
  3. 丢失:原始序列中的残基在另一条中消失。

例如:假定两条均包含7个核苷酸的DNA序列分别为s=CTGAAGC,  t=GGCTAAA

比对方式1

                s:             C  T  G  A  A  G  C

                t:    G  G  C  T      A  A     A

比对方式2

               s:            C  T  G  A  A  G  C

               t:    G  G  C  T  A  A  A

 哪种比对更好?还有哪些比对方式?为此,我们需要建立一个比对优劣的量化准则,基于该准则为每种方式赋予一个分值,具有最高分的比对方式作为判断同源问题的依据。

为研究方便,对给定的两个DNA序列st,假设对应位“匹配”得分为a,“替换” 则得分为-b,“增加”得分为-c,“丢失”得分都为-d。将序列s演变为序列t的最高得分f作为判断同源性的准则。

f超过某个阈值时,则称两个DNA序列是来自共同祖先的同源序列。

【标准输入】

输入有组测试数据不超过20,每组数据格式如下:          

第一行a   b  c  d             (4个整数 1 ≤ a , b, c ,d ≤ 20)

第二行: s                       (  | s| 300  )

第三行: t                       (  |t| 300  )

【标准输出】

对每组测试数据,输出占一行, 将序列s演变为序列t的最高得分f.

【 样  例 】

标准输入

标准输出

1 1 2 2

CTA

CTGAA

1 1 1 1

CDDAA

CAA

-1

1

 

C  DNA序列---变异问题                   Time Limit: 2000MS

    遗传是子代保持亲代特性的现象,变异是指子代与亲代存在不同之处。所谓突变,是指DNA序列在复制的过程中出现了可遗传性的改变。突变是某些遗传性疾病的主要原因。比如。染色体重组,基因突变等。其中,基因突变是造成变异的主要原因。

     在DNA序列中,基因突变可能将一种带有遗传信息的密码子变成另外一种未知信息。我们研究的是,对给定的一条变异的DNA序列片段,有多少密码子被改变的。

假设有n个不同的密码子A1, A2…, An,每个密码子都是由A,G,C,T 组成的长度10的字符串,并且任意密码子之间相互不为前缀。

给定一个由上述若干个密码子组成的原始DNA序列片段T长度500),和k个等长的有变异的DNA序列S1,S2…, Sk  你能否帮助Dr. Kong找到每条变异DNA片段中发生变异的密码子个数。

【标准输入】

输入有组测试数据不超过6,每组数据格式如下:

第一行:     n  k         1≤ n ≤ 100      1 ≤ k ≤ 10

接下来有M行:   A1,

……

An

第M+2   T      

接下来K行:  S1,

。。。。。。

Sk

【标准输出】

  输出每条变异DNA序列中发生变异密码子的个数。

【 样  例 】

标准输入

标准输出

5  2

GCT

ACT

AGTT

AAAAAGGGGG

CATAAGGAGA

AGTTACTACTAAAAAGGGGG

AGTTACCACTAAAAAGGGGG

GTCAACTGCTAACGAGGGGG

1

3

 

D  地铁1号线                                       Time Limit: 1000MS

    某市1号地铁线, 每天6:00 从始发站发出第一趟地铁,以后每隔 m 分钟发出下一趟,直到晚上22:00发出当日最后一趟地铁。

经过运行 X 年的数据分析发现,每趟地铁的车票收入与它的起发时间有一定关联。比如:6:00发出的地铁,由于坐车人数少,一趟下来车票收入为4.50千元;8:00发出的地铁,由于坐车人多,一趟下来车票收入为12.00千元。不同段时间内起发的地铁,车票收入满足不同的线性关系。

河南省第十二届ACM大学生程序设计竞赛试题_第1张图片

给出上述数据分析,地铁运营公司想知道,一天下来,1号地铁线总的车票收入是多少。

【标准输入】

第一行: T        表示以下有T组测试数据             ( 1≤ T ≤ 8

对每组数据,

第1行有两个整数 m  n ,接下来有n行,每行两个数据,格式为:  hh:mm  x  分别表示发车时间和车票收入 

其中:  10≤ m ≤ 60  1 ≤ n ≤ 100      0.00 ≤ x ≤ 100000.00

【标准输出】

对每组测试数据,输出一个实数,1号地铁线一天的车票总收入。(精确到小数点后2)

【 样  例 】

标准输入

标准输出

1

60  3

06:00  4.50

08:00  12.00

22:00  12.00

192.75

 

E  缆车                               Time Limit: 3000MS

在远离大陆的太平洋上,有一个风景优美的小岛。传说,小岛上的文明是这样发展起来的。

第一代人沿着岛的坡度选择了n 个定居点,编号为1,2,…,n. 其中编号 i 定居点的高度就是i米。他们在定居点的附近修建了房屋,开辟了农田,种植了植物。

第二代人在 n 个定居点之间修建了n-1条小路,每条小路连接两个定居点,且任意两个定居点之间都可以通过小路相互到达,互通有无。

各个定居点不仅高度不同,而且距离非常远.随着技术的提高,第三代人将盘岛小路改造成可以通缆车的道路。这样不同定居点的人们不费力气就可以借助缆车,自由地到达任何一个定居点。

为了纪念开辟文明的先辈,每年,小岛上都会举行一种特殊的仪式。每年的仪式会选择两个定居点x, y,人们将自己的思念和祝愿写成信件放入缆车,缆车将从定居点x 出发,沿着唯一的路径驶向定居点y。为了体会到翻山越岭的感觉, 岛民们希望缆车行车路线满足如下条件:

缆车依次经过若干定居点a1, a2…, ak,岛民们认为,如果存在i,在满足 1条件下,

         a1< a2<…..< ai    ai >ai+1 ……> ak

a1可以作为出发点,ak 可以作为终止点。

岛民想要知道,存在多少种不同路径的仪式方案? 所谓两个仪式方案不同,是指在满足约束条件下,如果他们的出发节点不同,或者结束点不同。

【标准输入】

第一行: T        表示以下有T组测试数据             ( 1≤ T ≤ 5

对每组数据,第1行: 一个整数n表示定居点个数。 接下来有n-1行,每行两个整数ai  aj,表示定居点ai到定居点aj之间有一条缆车路线。1 ≤ n ≤ 2* 105

【标准输出】

对每组测试数据,输出一个正整数,表示有多少种不同的仪式方案。

【 样  例 】

标准输入

标准输出

1

4

1 4

2 4

3 4

6

     

F  Information Transmission-1                               Time Limit: 1000MS

Information resources are information producers, information and information technology organisms. The fundamental purpose of information management is to control the flow of information and realize the utility and value of information. The broad meaning of information transmission is the transfer of information between media. Strictly speaking, all information processing is the transfer of information within the organization, that is, the movement of information in its physical location.

 

Information transmission methods include one-way transmission, two-way transmission, half-two-way transmission (only one direction per transmission), multi-channel transmission (one channel through multiple signals), etc.

 

Now, a university has a urgent notice, hoping all teachers can see the content at the first time. The physical location of all teachers is known , Once a teacher (xi,yi ) receives information,  he or she immediately passes it to another teacher in the adjacent position (xi+1,yi ) or (xi-1,yi ) or (xi,yi+1 ) or (xi,yi -1).

 

You can tell the authority , at first which teachers should be notified at least to ensure that everyone can see the notice content at the first time.

Input

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=8).  Each test case specify:

* Line 1:    m  n                  ( 1 ≤ m ≤ 200, 1 ≤ n ≤ 500  )

* Line 2~m+1:  Each row has n numbers, ‘1’ indicates that there is a teacher in this position.

Output

For each test case generate a single line:  minimum number of teachers to be notified first.

Sample  Input

Sample  Output
2
1 10
1110111111
7 9
000110000
110010001
010011011
000000000
111111100
010100100
111111100

5

17

 

 

G  Information Transmission-2                          Time Limit: 2000MS

Information plays a very important role in people's social life. For example, scientific research must not only obtain the results of others 'research in time, but also publish and inform others of the results of their own research in time. Only through this exchange of information can we continue to develop. Network communication is based on computer communication network for information transmission, exchange and utilization.

 

There are n base points and there is a certain transfer relationship between them., the information can be transmitted from point A to point B, and point B to point C, and so on.  Now there is a massage to be broadcasted ,  at least which base points to be sent the message first, so that all the base points can be received?

Input

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=8).  Each test case specify:

     * Line 1:      n           (2 ≤ n ≤ 100)

  *Line 2~n+1:  each line contains a 01 string of length n .

ie:if the sixth column in the third row is 1, it means that the third base point can pass the message to the sixth base point.

Output

For each test case generate a single line:  minimum number of base that the massage must be sent first, so that all the basis points can be received.

 

 

Sample Input

Sample Output

2

3

010

001

000

6

010000

001001

000100

010000

001000

000000

1

2

 

 

H   Information Transmission-3                          Time Limit: 2000MS  

There is n bases in a certain area,  numbered 1, 2,. .. .. , n,  the location of  base i  is represented by coordinates (xi, yi).  Dr. Kong is at point (x1, y1), he must send an information to point (xn, yn). Because of the insecurity of the network,  he decided to drive the information in person. When he is ready to leave, he find that there is something wrong with the steering wheel of his car. The steering wheel can only turn right and can not turn left.

 

All roads in the area are known . If there is a road from base i to base j, the path length of the road is calculated from the coordinates sqrt((xi-xj)2 +(yi-yj)2) ,  assuming that all roads are two-way.  At first, Dr. Kong may choose any road to set off  from base 1. Once he leaves, he can only go straight or turn right at a given coordinate point.  For faster transmission of information , Can you help Dr. Kong design a shortest path from Base 1 to Base n without turning left on the steering wheel?

Input

The first line of the input contains one integer T, which is the number of  test cases (1<=T<=5).  Each test case specifity:

* Line 1:            n  m     n bases, m roads    ( 1 ≤ n≤ 100, 1 ≤ m≤ 200  )

* Line 2~n+1:       xi  yi     the location of  base i  ( 2 integers, 0 xi , y i ≤ 1000 )

    * Line n+2~n+m+1:  ik  jk     there is a road from base ik to base jk

Output

For each test case generate a single line: a real number, the shortest path from Base 1 to Base n without turning left on the steering wheel.  accurate to 2 decimal places.

 

Sample  Input

Sample  Output

1

5 6

10 10

10 5

30 5

12 30

15 0

1 2

2 5

3 5

1 3

1 4

4 5

36.43

 

 

I  Destroy Base                                         Time Limit: 16 seconds

A base is developing chemicals of mass destruction. In order to prevent attack, there are several invisible protective panels above the base.

 

Now a army code TT01 receive a mission to destroy the base as soon as possible. At present, TT-1 is the most powerful weapon in the army. However, after many attacks, a difficult problem was found when TT-1 fires vertically at the base from above, it does not penetrate layers of protective panels, but slides down panels to the end point.  If the end point is within the range of the base, it can be destroyed, otherwise the base cannot be destroyed.

 

Good news, enhanced version of weapon TT-2 has been developed. It is based on TT-1 plus materials that can penetrate protective panels. Through the activation mechanism, TT-2 can choose to penetrate one layer, go on slide down panel, TT-2 can still choose to penetrate one layer......  It is a pity that every time TT2 breaks through a protective shield, the energy decreases. the energy decay formula is y=e-ax

 

For convenience, we transform this problem into two-dimensional space. The base is an interval [l, r] on the x-axis, invisible protective panels are modeled as line segments(x1,y1, x2,y2) above the x-axis. The panels are slanted, that is, not parallel to the x- or y-axes.  TT-2 fires vertically from above. When any TT-2 fires on a panel, it can flows toward the panel’s lower end and falls off from there. But the penetration mechanism is activated, it can also penetrate one layer instead. After TT-2 falls off a pannel, it continues to fall vertically. This repeats until  TT-2 hits the base. Finally, maximum destructive power of TT2 to the base as follows:

                             Z=t/w*e-ax

t is the initial energy of TT2, w is base length , x is number of TT2 penetrate the panels, a is given parameter. due to the rarity of penetrating materials, we need to know how many penetration mechanisms can be activated at least to hit the base point ,  how much damage can be achieved.

Input

The first line of input contains five integers t, a, l, r and n, where [l, r] is the Left and right boundary of the base and n is the number of panels. Each of the following n lines describes a panel and contains four integers x1, y1, x2, y2.

 

Where t is a integer , a is a real number , l, r, x, y are integers. and x1 and x2 for all panels are all distinct. The pannels described in the input will not intersect, and no endpoint of a panel will lie on another panel.

(   102 ≤ t ≤ 109 ,  0.00

0 ≤ n ≤ 5 · 105 ,  0 ≤ x1, x2 , y1 , y2≤ 109  x1 ≠x2,  y1 ≠y2,  ).

Output

The maximum destructive power of TT2 to the base, accurate to 3 decimal places

 

Sample  Input  

Sample  Output

800 0.192540 10 20 2

5 2 15 15

2 80 25 70

82.592

        

J  Special Formation                                      Time Limit: 1000ms

A large number of new microbes have been found in an uninhabited island. Strangely, these microbes, how ever active during the day, end up resting at night in the following pattern. It’s very much like an infinite full binary search tree .

http://poj.org/images/2309_1.jpg

You might as well number these microbes as 1,2,3.. .... In a subtree whose root node is ith, we can get the minimum number in this subtree by repeating going down the left node until the last level, and we can also find the maximum number by going down the right node. Now you are given some queries as "What are the minimum and maximum numbers in the subtree whose root node is ith?" Please try to find answers for there queries.

Input

The first line contains an integer N, which represents the number of queries (1≤ N ≤ 20). In the next N lines, each contains a number representing a subtree with root number xi  (2≤ xi ≤ 231 - 1).

Output

There are N lines in total, the i-th of which contains the answer for the i-th query.

 

Sample  Input

Sample  Output

3

3

8

20

3 3

1 15

17 23

你可能感兴趣的:(我的竞赛)