ACM竞赛试题(英文)

更新时间:2023-07-13 20:32:35 阅读: 评论:0

Problem A. Naughty fairies
Description
Once upon a time, there lived a kind of fairy in the world. Tho fairies could hear the voice of fruit trees, and helped people with a harvest. But people didn’t know that fruits are also tho fairies’ favorite food. After the fairies ate people’s fruits, they always did something to cover it up.
One day a little fairy named Lily flew into an orchard and found a large peach tree. Hungry as Lily was, she started eating without thinking until her stomach was full. In the fairy world, when a fairy ate the fruits in a fruit tree, sometimes the fruit tree would feel honored and bore more fruits immediately. That’s why sometimes the number of fruits in a tree got incread after a fairy ate fruits of that tree.
But the fairies didn’t want people to find out weird things such as fruits become more or less suddenly. Lily decided to u a magic spell so that the orchard owner couldn’t find the change of the number of peaches.
Suppo there were N peaches on a tree originally and there were M peaches left after Lily was full. M may be greater than, less than or equal to N. All M peaches were visible at first, and Lily wanted to make an illusion so that exactly N peaches are visible.
Lily can do 3 kinds of spell to change the total visible number of peaches:
1) “PAPADOLA”:This spell would increa the number of visible peaches by one.
2) “EXPETO POTRONUM”:This spell would double the number of visible peaches.
3) “SAVIDA LOHA”:This spell would decrea the number of visible peaches by one.
Each spell would take one minute and Lily wanted to finish as fast as possible. Now plea tell Lily the least time she needs to change the number of visible peaches to N.
Input
There are veral test cas, ended by “0 0”.
For each test ca, there are only one line containing two numbers parated by a blank, N and M, the original numbers of peaches and the numbers of peaches left(0<N,M<10500).There is no leading zero.
Output
For each test ca, you should output just a number K indicating the minimum time (in minutes) Lily needed to finish her illusion magic.
Sample Input
5 2
1 99
86 32
0 0
Sample Output
2
98
12
Problem B. Prison Break
怎么画水粉画Description
Rompire is a robot kingdom and a lot of robots live there peacefully. But one day, the king of Rompire was captured by human beings. His thinking circuit was changed by human and thus became a tyrant. All tho who are against him were put into jail, including our clever Micheal#1. Now it’s time to escape, but Micheal#1 needs an optimal plan and he contacts you, one of his human friends, for help.
The jail area is a rectangle contains n×m little grids, each grid might be one of the following:
1) Empty area, reprented by a capital letter ‘S’. 水母的寿命
2) The starting position of Micheal#1, reprented by a capital letter ‘F’.
3) Energy pool, reprented by a capital letter ‘G’. When entering an e
nergy pool, Micheal#1 can u it to charge his battery ONLY ONCE. After the charging, Micheal#1’s battery will become FULL and the energy pool will become an empty area. Of cour, passing an energy pool without using it is allowed.
4) Lar nsor, reprented by a capital letter ‘D’. Since it is extremely nsitive, Micheal#1 cannot step into a grid with a lar nsor.
5) Power switch, reprented by a capital letter ‘Y’. Once Micheal#1 steps into a grid with a Power switch, he will certainly turn it off.
In order to escape from the jail, Micheal#1 need to turn off all the power switches to stop the electric web on the roof—then he can just fly away. Moving to an adjacent grid (directly up, down, left or right) will cost 1 unit of energy and only moving operation costs energy. Of cour, Micheal#1 cannot move when his battery contains no energy.
The larger the battery is, the more energy it can save. But larger battery means more weight and higher probability of being found by the weight nsor. So Micheal#1 needs to make his battery as small as possible, and still large enough to hold all energy he need. Assuming that the size of the battery equals to maximum units of energy that can be saved in the battery, and Micheal#1 is fully charged at the beginning, Plea tell him the minimum size of the battery needed for his Prison break.
Input
Input contains multiple test cas, ended by 0 0. For each test ca, the first line contains two integer numbers n and m showing the size of the jail. Next n lines consist of m capital letters each, which stands for the description of the jail.
You can assume that 1<=n,m<=15, and the sum of energy pools and power switches is less than 15.
Output
For each test ca, output one integer in a line, reprenting the minimum size of the battery Micheal#1 needs. If Micheal#1 can’t escape, output -1.
Sample Input
5 5
GDDSS
SSSFS
SYGYS
SGSYS
SSYSS
0 0
Sample Output
4
Problem C. To Be an Dream Architect
Description
男生颧骨高The “dream architect” is the key role in a team of “dream extractors” who enter other’s dreams to steal crets. A dream architect is responsible for crafting the virtual world that the team and the target will dream into. To avoid the target noticing the world is artificial, a dream architect must have powerful 3D imagination.
Cobb us a simple 3D imagination game to test whether a candidate has the potential to be an dre
am architect. He lets the candidate imagine a cube consisting of n×n×n blocks in a 3D coordinate system as Figure 1. The block at bottom left front corner is marked (1, 1, 1) and the diagonally opposite block is marked (n, n, n). Then he tells the candidate that the blocks on a certain line are eliminated. The line is always parallel to an axis. After m such block eliminations, the candidate is asked to tell how many blocks are eliminated. Note that one block can only be eliminated once even if it is on multiple lines.
He
re is a sample graph according to the first test ca in the sample input:
Input
The first line is the number of test cas.
In each test ca, the first line contains two integers n and m( 1 <= n <= 1000, 0 <= m <= 1000).,meaning that the cube is n x n x n and there are m eliminations.
Each of the following m lines reprents an elimination in the following format:
axis_1=a, axis_2=b
where axis_i (i=1, 2) is ‘X’ or ‘Y’, or ‘Z’ and axis_1 is not equal to axis_2. a and b are 32-bit signed integers.
Output
For each test ca output the number of eliminated blocks.
心疼的句子Sample Input
打量的读音2
3 2
Y=1,Z=3
X=3,Y=1
10 2
X=3,Y=3
Y=3,Z=3
Sample Output
5
19
Problem D. Gomoku
Description
You are probably not familiar with the title, “Gomoku”, but you must have played it a lot. Gomoku is an abstract strategy board game and is also called Five in a Row, or GoBang. It is traditionally played with go pieces (black and white stones) on a go board (19x19 interctions). Nowadays, standard chessboard of Gomoku has 15x15 interctions. Black plays first, and players alternate in placing a stone of their color on an empty interction. The winner is the first player to get an unbroken row of five or more stones horizontally, vertically, or diagonally.
For convenience, we coordinate the chessboard as illustrated above. The left-bottom interction is (0,0). And the bottom horizontal edge is x-axis, while the left vertical line is y-axis.
I am a fan of this game, actually. However, I have to admit that I don’t have a sharp mind. So I need a computer program to help me. What I want is quite simple. Given a chess layout, I want to know whether someone can win within 3 moves, assuming both players are clever enough. Take the picture above for example. There are 31 stones on it already, 16 black ones and 15 white ones. Then we know it is white turn. The white player must place a white stone at (5,8). Otherwi, the black player will win next turn. After that, however, the white player also gets a perfect situation that no matter how his opponent moves, he will win at the 3rd move.
So I want a program to do similar things for me. Given the number of stones and positions of them, the program should tell me who turn it is, and what will happen within 3 moves.
沟通是什么
Input
The input contains no more than 20 cas.
Each ca contains n+1 lines which are formatted as follows.
n
x1 y1 c1
x2 y2 c2
......
xn yn cn
The first integer n indicates the number of all stones. n<=222 which means players have enough space to place stones. Then n lines follow. Each line contains three integers: xi and yi and ci. xi and yi are coordinates of the stone, and ci means the color of the stone. If ci=0 the stone is white. If ci=1 the stone is black. It is guaranteed that 0<=xi,yi<=14, and ci=0 or 1. No two stones are placed at the same position. It is also guaranteed that there is no five in a row already, in the given cas.
The inp
ut is ended by n=0.
Output
For each test ca:
First of all, the program should check who turn next. Let’s call the player who will move next “Mr. Lucky”. Obviously, if the number of the black stone equals to the number of white, Mr. Lucky is the black player. If the number of the black stone    equals to one plus the numbers of white, Mr. Lucky is the white player. If it is not the first situation or the cond, print “Invalid.”
A valid chess layout leads to four situations below:
1) Mr. Lucky wins at the 1st move. In this situation, print :
Place TURN at (x,y) to win in 1 move.
“TURN” must be replaced by “black” or “white” according to the situation and (x,y) is the position of the move. If there are different moves to win, choo the one where x is the smallest. If there are still different moves, choo the one where y is the smallest.
2) Mr. Lucky’s opponent wins at the 2nd move. In this situation, print:
Lo in 2 moves.
3) Mr. Lucky wins at the 3rd move. If so, print:
Place TURN at (x,y) to win in 3 moves.
“TURN” should replaced by “black” or “white”, (x,y) is the position where the Mr. Lucky should place a stone at the 1st move. After he place a stone at (x,y), no matter what his opponent does, Mr. Lucky will win at the 3rd step. If there are multiple choices, do the same thing as described in situation 1.
4) Nobody wins within 3 moves. If so, print:
Cannot win in 3 moves.
Sample Input
31
3 3 1
3 4 0
3 5 0
3 6 0
4 4 1
4 5 1
4 7 0
5 3 0
5 4 0
5 5 1
5 6 1
5 7 1
5 9 1
6 4 1
6 5 1
6 6 0
6 7 1
6 8 0
玉石鉴定方法
6 9 0
7 5 1
7 6 0
7 7 1
7 8 1
7 9 0
8 5 0
8 6 1
8 7 0
8 8 1
8 9 0
9 7 1
10 8 0
1
7 7 1
1
7 7 0
0
Sample Output
Place white at (5,8) to win in 3 moves.
Cannot win in 3 moves.
Invalid.
Problem E. Gunshots
Description
President Bartlet was shot!  A group of terrorists shot to the crowd when President Bartlet waved to cheering people after his address. Many people were shot by the irrational bullets. Senior FBI agent Don Epps takes responsibility for this ca. According to a ries of crime scene investigation, including analyzing shot shells, replaying video from clod-circle television and collecting testimony by witness, Don keeps all the information about where and how the terrorists shot to crowd, as well as the location of every single person when the gun shoot happened.  Now he wants to know how many gunshot victims are there in this ca.
Imagine that each target person can be regarded as a polygon (can be concave or lf-intercting) and each gunshot can be regarded as a half-line. The bullet will be stopped by the first person it sho
ots. A person can be shot in three ways: 
To simplify the problem, we assume that any two polygons can be completely parated by a line. Also each start point of the gunshot can be parated from each polygon by a line. Now given M people and N gunshots, plea work out whic
h person has been shot by each bullet.
Input
There are multiple test cas in the input. The first line of the input file is an integer T demonstrating the number of test cas. (T<=10).
For each test ca, the first line is an integer N, reprenting the number of people (polygons). Following lines demonstrates the polygons. For the ith polygon (0<=i<N), the first line is an integer Qi, reprenting the number of edges of this polygon. In each of the following Qi lines, there are two real numbers xi and yi reprenting a point. Every pair of adjacent points demonstrate an edge of this polygon (i.e. (xi, yi) to (xi+1, yi+1) is an edge, in which 0<=i<Qi-1), and (xQi-1, yQi-1) to (x0, y0) also demonstrates an edge of this polygon.
Then there is a line contains an integer M reprenting the number of gunshots. In the following M lines, each line contains four real numbers x, y, dx and dy, reprenting the start point (x, y) and direction vector (dx, dy) of that gunshot.
In all test cas, we assume that 0< N<=100, 0<Qi<=1000, 0<M<=10000.
Output
For each test ca, output contains M lines and the ith line demonstrates the result of the ith gunshot.
If the ith gunshot shoots the jth polygon, the ith line contains “HIT j”, otherwi it contains a word “MISS” (means that it does not shoot any target). The polygons are numbered in the order of their appearance in the input file, and the numbers start from 0.
At the end of each test ca, plea output a single line with “*****”.
Sample Input
1
1
4
0 0
1 1
0 1
1 0
2
-1 0 1 0
-2 0 -1 0
Sample Output
HIT 0
MISS
*****
Hint
The figure of the first ca in the samples is as follows:
Problem F. Rotational Painting
Description
Josh Lyman is a gifted painter. One of his great works is a glass painting. He creates some well-designed lines on one side of a thick and polygonal glass, and renders it by some special dyes. The most fantastic thing is that it can generate different meaningful paintings by rotating the glass. This method of design is called “Rotational Painting (RP)” which is created by Josh himlf.
You are a fan of Josh and you bought this glass at the astronomical sum of money. Since the glass is thick enough to put erectly on the table, you want to know in total how many ways you can put it so that you can enjoy as many as possible different paintings hiding on the glass. We assume that m
香椿炒鸡蛋的做法
aterial of the glass is uniformly distributed. If you can put it erectly and stably in any ways on the table, you can enjoy it.
More specifically, if the polygonal glass is like the polygon in Figure 1, you have just two ways to put it on the table, since all the other ways are not stable. However, the glass like the polygon in Figure 2 has three ways to be appreciated.
Pay attention to the cas in Figure 3. We consider that tho glass are not stable.
Input
The input file contains veral test cas. The first line of the fil

本文发布于:2023-07-13 20:32:35,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1094885.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:水母   颧骨   读音   鉴定   炒鸡蛋
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图