TASKS

SAMPLES | DAY 1 | DAY 2 |

Sample Tasks for Practice


1. Numbers



PROBLEM

You are to write a program, which, given N positive integer values X1, X2,. . ., XN, computes the smallest number Xi that appears in the sequence at least as many times as any other number.

INPUT

The output file name is numbers.out. The the first line is to contain one integer, the smallest number to appear at least as many times as any other number.

EXAMPLE INPUTS AND OUTPUTS

inputoutput
10
1
2
3
4
5
3
2
3
1
2
2

CONSTRAINS

In all inputs, 2 ≤ N ≤ 1000, and for each Xi , 1 ≤ Xi ≤ 10000.

SCORING

If your program outputs the correct answer for a test case within the time limit, then you get full points for that test case, and otherwise you get 0 points for that case.



2. Olympic Avenues



PROBLEM

In Athens 2004 Olympic Games there were many Olympic sites (Stadiums, Olympic Village, Press Center, Offices, etc.). For the athletes, officials and press people to move fast between Olympic sites, Athens created what were called "Olympic Avenues" where only Olympic buses could move. Each Olympic avenue connects two Olympic sites. Not all Olympic sites are connected directly by an Olympic avenue. Each Olympic avenue connects exactly two Olympic sites. A bus driver is traveling from one Olympic site to another and she wants to travel only on the Olympic Avenues. Given the information about the Olympic sites and avenues, you are to help her to find a shortest route between two Olympic sites using only Olympic avenues.

INPUT

You are given 4 problem instances in the text files named olympic1.in to olympic4.in. Each input file is organized as follows. The first line contains one integer: the number of Olympic sites, N, 5 ≤ N ≤ 50. Line 2 contains two integers S and F: the numbers of the starting and the ending sites of the route. The next line contains one integer L: the number of Olympic avenues. The following L lines describe these Olympic avenues. Each of these lines contain three integers I, J, and D: the first two are the Olympic sites I and J that are connected by the avenue and the third integer D is the distance between I and J. This way, the input is organized in the following form:

N
S F
L
I1 J1 D1
I2 J2 D2
. . .
IL JL DL


OUTPUTS

You are to submit 4 output files corresponding to the given input files. You do not need to submit your solution program source. The first line is to contain the text #FILE olympic I where integer I is the number of the respective input file. The second line is to contain one integer: the length of the shortest route from S to F. The third line is to contain a sequence of integers: the numbers of the Olympic sites visited on the shortest route, where S is the first integer in the sequence and F is the last integer in the sequence.

EXAMPLE INPUTS AND OUTPUTS

olympic0.in olympic0.out
6
1 4
8
1 2 12
1 6 8
1 3 20
6 5 10
5 4 7
5 3 2
3 4 6
2 3 5

#FILE olympic 0
23
1 2 3 4


SCORING

If the distance in your answer corresponds to the tour in your answer, and the tour is as short as possible, you get a full score for that file. Otherwise your score is zero for that file.