河南省第八届ACM程序设计竞赛(未完再续)

  • 题目1236

挑战密室

时间限制:1000 ms  |  内存限制:65535 KB
难度:4
描述

R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室。Dr. Kong必须尽快找到解锁密码逃离,否则几分钟之后,WTO密室即将爆炸。

 

Dr. Kong发现密室的墙上写了许多化学方程式中。化学方程式,也称为化学反应方程式,是化学式表示物质化学反应的式子。化学方程式反映的是客观事实。因此书写化学方程式要遵守两个原则:一是必须以客观事实为基础;二是要遵守质量守恒定律。

化学方程式不仅表明了反应物、生成物和反应条件。同时,化学计量数代表了各反应物、生成物物质的量关系,通过相对分子质量或相对原子质量还可以表示各物质之间的质量关系,即各物质之间的质量比。对于气体反应物、生成物,还可以直接通过化学计量数得出体积比。例如:2NaOH+H2SO4=Na2SO4+2H2O

 

经过多次试探、推理,Dr. Kong发现密码是4位数字,就隐藏在化学方程式等号后的第一个分子中,其分子量就可能是密码(若分子量不足4位,前面加0)。

好在Dr. Kong还记得墙上各化学方程式用到的化学元素的原子量如下:

 

N

C

O

Cl

S

H

Al

Ca

Zn

Na

14

12

16

35

32

2

27

40

65

23

 

你能帮Dr. Kong尽快找到密码吗?

输入
第一行: K,表示有K个化学方程式;
接下来有K行,每行为一个化学方程式
输出
对于每个化学方程式输出一行:即密码。
样例输入
3
2C+O2=2CO
2NaOH+H2SO4=Na2SO4+2H2O
Ca2CO3+H2O=Ca2(OH)2+CO2
样例输出
0056
0142
0116
提示
2≤K≤8 ,化学方程式的长度不超过50, 所有原子,分子的数量不超过9.小括号最多一层.
来源
第八届河南省程序设计大赛
上传者

hnu_acm



最大岛屿

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描述

神秘的海洋,惊险的探险之路,打捞海底宝藏,激烈的海战,海盗劫富等等。加勒比海盗,你知道吧?杰克船长驾驶着自己的的战船黑珍珠1号要征服各个海岛的海盜,最后成为海盗王。  这是一个由海洋、岛屿和海盗组成的危险世界。面对危险重重的海洋与诡谲的对手,如何凭借智慧与运气,建立起一个强大的海盗帝国。

杰克船长手头有一张整个海域的海图,上面密密麻麻分布着各个海屿的位置及面积。他想尽快知道整个海域共有多少岛屿以及最大岛屿的面积。

输入
第1行:M N T,表示海域的长,宽及一个单位表示的面积大小
接下来有M行 ,每行有N个01组成的序列以及其中穿插一些空格。0表示海水,1表示陆地,其中的空格没用,可以忽略掉。

输出
输出一行,有2个整数,一个空格间隔,表示整个海域的岛屿数,以及最大岛屿的面积
样例输入
8 16 99
00000000 00000000
0000110011000000
0001111000111000
0000000  00 0000000
00111  111000001  10
001110000  0000000
0100001111 111100
0000000000000000
样例输出
5 990
提示
①若一个陆地八个方向之一(上、下、左、右、左上、右上、左下、右下)的位置也是陆地,则视为同一个岛屿。
② 假设第一行,最后一行,第一列,最后一列全为0.
③ 1<M, N≤500 1<T≤100000
来源
第八届河南省程序设计大赛
上传者
hnu_acm

最少换乘

时间限制: 2000 ms  |  内存限制: 65535 KB
难度: 3
描述

 欧洲某城是一个著名的旅游胜地,每年都有成千上万的人前来观光旅行。Dr. Kong决定利用暑假好好游览一番。。

年轻人旅游不怕辛苦,不怕劳累,只要费用低就行。但Dr. Kong年过半百,他希望乘坐BUS从住的宾馆到想去游览的景点,期间尽可量地少换乘车。

 

Dr. Kon买了一张旅游地图。他发现,市政部门为了方便游客,在各个旅游景点及宾馆,饭店等地方都设置了一些公交站并开通了一些单程线路。每条单程线路从某个公交站出发,依次途经若干个站,最终到达终点站。

但遗憾的是,从他住的宾馆所在站出发,有的景点可以直达,有的景点不能直达,则他可能要先乘某路BUS坐上几站,再下来换乘同一站的另一路BUS, 这样须经过几次换乘后才能到达要去的景点。

 

为了方便,假设对该城的所有公交站用12……N编号。Dr. Kong所在位置的编号为1,他将要去的景点编号为N

请你帮助Dr. Kong寻找一个最优乘车方案,从住处到景点,中间换车的次数最少。

输入
第一行: K 表示有多少组测试数据。(2≤k≤8)
接下来对每组测试数据:
第1行: M N 表示有M条单程公交线路,共有N站。(1<=M<=100 1<N<=500)
第2~M+1行: 每行描述一路公交线路信息,从左至右按运行顺序依次给出了该线路上的所有站号,相邻两个站号之间用一个空格隔开。
输出
对于每组测试数据,输出一行,如果无法乘坐任何线路从住处到达景点,则输出"N0",否则输出最少换车次数,输出0表示不需换车可以直达。
样例输入
2
3 7
6 7
4 7 3 6
2 1 3 5
2 6
1 3 5
2 6 4 3
样例输出
2
NO
来源
第八届河南省程序设计大赛
上传者
hnu_acm

引水工程

时间限制:2000 ms  |  内存限制:65535 KB
难度:3
描述

南水北调工程是优化水资源配置、促进区域协调发展的基础性工程,是新中国成立以来投资额最大、涉及面最广的战略性工程,事关中华民族长远发展。“南水北调工程”,旨在缓解中国华北西北地区水资源短缺的国家战略性工程。就是把中国长江流域丰盈的水资源抽调一部分送到华北和西北地区。我国南涝北旱,南水北调工程通过跨流域的水资源合理配置,促进南北方经济、社会与人口、资源、环境的协调发展。

整个工程分东线、中线、西线三条调水线。东线工程位于东部,因地势低需抽水北送至华北地区。中线工程从汉水与其最大支流丹江交汇处的丹江口水库引水,自流供水给黄淮海平原大部分地区,20多座大中城市;西线工程在青藏高原上,由长江上游向黄河上游补水。

现在有N个区域需要建设水资源工程,它们可以自建水库解决缺水问题,也可以从已有水源的地区建立管道引水过来。当然,这些建设都需要大量投资。

你能不能给出一个优化水资源配置方案,在保证每个区域都能用上水的前提下,使得整个引水工程费用最低。

输入
第一行: K 表示有多少组测试数据。
接下来对每组测试数据:
第1行: N 表示有N个区域( 1<=N<=300 )
第2 行: W1 W2 …. WN Wi表示第i个区域自建水库需要的费用
再有N行: Pi1 Pi2 …. Pin Pij表示建立第i个区域与第j个区域引水管道的费用
输出
对于每组测试数据,输出占一行,即建立整个引水工程的最小费用。
样例输入
1
5
5 4 4 3 6
0 2 2 2 2
2 0 3 3 3
2 3 0 4 5
2 3 4 0 1
2 3 5 1 0
样例输出
10
来源
第八届河南省程序设计大赛
上传者
hnu_acm

疫情控制

时间限制:3000 ms  |  内存限制:65535 KB
难度:3
描述

据某省水产部门通报,A市大面积范围水产养殖区爆发ADH氏菌疫情,导致大量鱼苗死亡,养殖户经济损失巨大。必须尽快控制疫情,使水产养殖秩序回归正常。

此次ADH氏菌疫情传染范围较大,涉及到 M 个地区。要想对某个地区I疫情进行控制,必须先控制住上游地区I-1的疫情,再对该地区监测,管理,施药才能彻底清除传染性,真正做到水体改良,水质改善。

 

不妨设M 个地区的编号1,2,…,M,首先,地区1的疫情得到控制后,才能在1天后控制地区2。类推,仅当地区i的疫情得到控制后,1天后才能去控制地区i+1;当第M个地区疫情被控制后,才算彻底控制住A市疫情。

 

如何做到早发现,早报告,早隔离,早治理,按照属地化管理原则,A市准备建立 N 个防疫中心。当一个防疫中心启用后,它可以对方圆半径 R 范围内的地区疫情加以控制,并且持续控制5天。N 个防疫中心也不是同时启动,当一个防疫中心启用5天后,才能启动另一个防疫中心。

 

启用一个防疫中心需要大量的人力,物力。请你设计一个方案,如何启用尽可能少的防疫中心就能够对A市所有疫情加以控制。

输入
第一行: K 表示有多少组测试数据。 
接下来对每组测试数据:
第1行: M N R 
第2~M+1行: X1i Y1 i 表示第 i 地区所在的坐标 i=1,…,M
第M+2~M+N+1行: X2 j Y2j 表示第 j 防疫中心的坐标 j=1,…,N
1≤K≤5 1 ≤M, N ≤ 100,1≤ R≤1000, 0≤所有坐标X,Y≤10000
所有数据都是整数。 数据之间有一个空格。
输出
对于每组测试数据,输出占一行:最少启用的防疫中心数量
样例输入
1
4 3 6
0 6
6 6
6 0
0 0
0 3
1 1
1 5
样例输出
2 
提示
启用3号防疫中心可以控制地区1,2
启用2号防疫中心可以控制地区3,4
来源
第八届河南省程序设计大赛
上传者
hnu_acm



Distribution

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述

One day , Wang and Dong in the Dubai desert expedition, discovered an ancient castle. Fortunately, they found a map of the castle.The map marks the location of treasures.

They agreed to distribute the treasures according to the following rules:



Wang draws a horizontal line on the map and then Dong draws a vertical one so that the map is divided into 4 parts, as show below. 

Wang will save the treasures in I and III ,while those situated in II and IV will be taken away by Dong. Wang first draw a horizontal line, Dong after the draw a vertical line.

They drew several pairs of  lines. For each pair, Wang wants to know the difference between their treasures.

It's guaranteed that all the reasures will lie on neither of the lines drew by them.

输入
the first line contains two integers N and M, where N is the number of treasures on the map and M indicates how many times they are going to draw the lines. The 2nd to (N+1)-th lines Xi, Yi contain the co-ordinates of the treasures and the last M lines consist of the M pairs integers (X, Y) which means that the two splitting lines intersect at point (X, Y).
( 0 < N, M ≤ 100, 0 ≤ Xi, Yi, X,Y ≤ 1000 )
输出
Output contains M lines , a single line with a integer , the difference described above
样例输入
10 
29 22
17 14 
18 23
3 15
6 28
30 27
4 1
26 7
8 0
11 21
2 25
5 10
19 24
样例输出
-6
4
4
来源
第八届河南省程序设计大赛
上传者
hnu_acm


Interference Signal

时间限制:2000 ms  |  内存限制:65535 KB
难度:1
描述

Dr.Kong’s laboratory monitor some interference signals. The interference signals can be digitized into a series of positive integer. May be, there are N integers a1,a2,…,an.

 

Dr.Kong wants to know the average strength of a contiguous interference signal block. the block must contain at least M integers.

 

Please help Dr.Kong to calculate the maximum average strength, given the constraint.

输入
The input contains K test cases. Each test case specifies:
* Line 1: Two space-separated integers, N and M.
* Lines2~line N+1: ai (i=1,2,…,N)
1 ≤ K≤ 8, 5 ≤ N≤ 2000, 1 ≤ M ≤ N, 0 ≤ ai ≤9999
输出
For each test case generate a single line containing a single integer that is 1000 times the maximal average value. Do not perform rounding.
样例输入
10 6
4
2
10
3
8
5
9
4
1
5 2
10
3
8
9 
样例输出
6500
7333
来源
第八届河南省程序设计大赛
上传者
hnu_acm



Radition Protection Wall

时间限制:3000 ms  |  内存限制:65535 KB
难度:5
描述

A military base in the tested nuclear weapons, an explosion because of failure. In order to prevent nuclear radiation leakage,  it is necessary to establish  a closed house.

 

The closed house  is a convex polygon in the wall,  will be constructed of  N or fewer connected straight wall segments (3 <= N <=100),  forming a polygon  which contains  the location of the nuclear leak (X0,Y0). 

 

Due to the complex terrain of the military base and the cost , the chief has obtained from his contractor  a list of prices for building wall segments at various locations. He could potentially build N different wall segments, and he knows the coordinates of the endpoints and cost for each of these segments.  The location of the nuclear leak does not lie on any endpoints (X,Y) coordinates between -10000 and 10000,  and  does not lie directly on any of the potential wall segments.  

 

Determine the minimum-cost set of wall segments that forms a convex polygon containing the location of the nuclear leak.

输入
The input contains K test cases (1<=K<=5). Each test case specifies:
* Line 1: N X0 Y0 
* Lines 2..N+1: Five space-separated integers describing a potential wall segment. 
the first two integers are the X and Y,coordinates of one endpoint; 
the next two integers are the X and Y coordinates of the second endpoint; the last integer is the cost C of building that wall (1 <= C <= 10000).
输出
For each test case generate a single line containing a single integer that is the cost of the cheapest set of walls which form a legal prison or -1 if no such prison can be constructed
样例输入
1
8 1 1 
0 0 0 3 2
0 0 3 1 2
3 1 2 3 2
0 3 1 2 1
1 2 2 3 1
0 3 2 3 4
1 2 0 0 8
3 1 0 3 8
样例输出
10
来源
第八届河南省程序设计大赛
上传者
hnu_acm

* Line 1: N X0 Y0 
* Lines 2..N+1: Five space-separated integers describing a potential wall segment. 
the first two integers are the X and Y,coordinates of one endpoint; 
the next two integers are the X and Y coordinates of the second endpoint; the last integer is the cost C of building that wall (1 <= C <= 10000).
输出
For each test case generate a single line containing a single integer that is the cost of the cheapest set of walls which form a legal prison or -1 if no such prison can be constructed
样例输入
1
8 1 1 
0 0 0 3 2
0 0 3 1 2
3 1 2 3 2
0 3 1 2 1
1 2 2 3 1
0 3 2 3 4
1 2 0 0 8
3 1 0 3 8
样例输出
10
来源
第八届河南省程序设计大赛
上传者
hnu_acm
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值