4th Round: 5th of February 1997

1st Problem
2nd Problem
1st Problem: The folding of the maps (45 points)


A strategical map is represented as an array with n lines and m columns (1<=n , m<=100), each component part containing the height of the land area measured in metres from the sea level, this height being a positive integer. Find out a way to fold the map so that on the top there must be a surface of maximum area having the same height.The folding of the map is allowed only on horizontal and vertical ( so on lines parallel with the sides of the map) and only in two equal parts( if the size of the paper is an odd number, the folding along that side is not possible). The area of the zone so determined and the corresponding height will appear on the screen, as well as the codes of the foldings, using the following convention : first indicate the direction ( H-horizontal; V-vertical ) , then the position from which the folding is made, then the manner of folding ( L- left side over; R- right side over; U- upper side over ; D- down side over) two consecutive foldings being separated by space. If the problem doesn't have a solution, print the message "Bad luck".
Input/output restrictions :
The name of the file will be read from the keyboard. The input file contains on the first line n and m , the size of the paper, separated by space and on the next n lines m positive integers which represent the heights.
The output file will be named map.out and will contain :
on the first line the message "Maximum area" followed by the maximum value of the area
on the second line the message "Height" followed by the value of the common height of the determined area
on the third line the codes of the foldings
or
the message "Bad luck", if there is no solution.

Example:
For the input file :
     3 4
     1 1 1 1
     2 2 2 2
     2 2 2 2
The output file will contain the message "Bad luck"
for the input file :
     4 4
     1 1 1 1
     2 1 3 4
     1 2 3 4
     2 2 2 2
The output file :
  Maximum area 4
  Height 1
  H2U H1U

or

  Maximum area 4
  Height 2
  H3D H4D

Attention ! If there are several solutions, only one will be printed !

prof. Emanuela Mateescu
"Grigore Moisil" Highschool, Iasi

2nd Problem: Contest (45 points)


Considering the points of an infinite array of triangles, like the following ones:


Groups of these points make the vertexes of some geometrical figures.
For example:
{1,2,3} and {7,9,11} are the vertexes of triangles; {11,13,26,24} and {2,7,9,18} are the vertexes of parallelograms; {4,5,9,13,12,7} and {8,10,17,21,32,34} are the vertexes of hexagons.

Make a program which reads several sets of dates, analyses them and decides wether the points are the vertexes of geometrical figures:triangle, parallelogram or hexagon. For obtaining a correct figure, it has to fulfil the conditions:
1. each side to coincide with a side of the array
2. the sides of the figures to be equal

The information will be read from the file "input" which containes several sets of dates, each set on a line.There are 6 numbers on a line at most, between 1 and 32767.
The result is printed in the file "output" and consists of: the reading of the numbers followed by the result of the analyse.

Example :
File "input":
     1 2 3
     11 13 29 31
     26 11 13 24
     4 5 9 13 12 7
     1 2 3 4 5
     47
     11 13 23 25
File "output":
     1 2 3 are the vertexes of a triangle;
     11 13 29 31 are not the vertexes of a convenient  figure;
     26 11 13 24 are the vertexes of a parallelogram;
     4 5 9 13 12 7 are the vertexes of a hexagon;
     1 2 3 4 5 are not the vertexes of a convenient figure;
     47 are not the vertexes of a convenient figure;
     11 13 23 25 are not the vertexes of a convenient figure.

ACM contest 1991

[Index] [Important Informations] [Participants] [3rd Round] [5th Round]