Vous êtes sur la page 1sur 8

UC Anniversary Programming Contest 2011

Contest Session
Universidad de Carabobo, Venezuela
Sponsored by:
July 09, 2011
This problem set should contain a rules section and four (04) problems on seven (07) numbered pages. Please
inform the Contest Sta immediately if something is missing from your problem set.
Welcome to the Programming Contest and enjoy it!
Rules
Each team will be provided with a single computer. All teams will have equivalent computing equipment.
There are four (04) problems for each team to be completed in four (04) hours.
All problems require that you read test data from the standard input and write results to the standard output.
You may use any of the following programming languages: C, C++ or Java. You may use dierent program-
ming languages for dierent problems and even for dierent submissions of a problem.
All problems have a source le name shown below the title of the problem. The extensions you must use for
your source les are: .c for programs written in C, .cpp for those in C++, and .java for those in Java.
You may use any of the standard libraries that your chosen programming language provides. You may not
use any other library that requires an extra ag to be passed to the compiler command. If you do this, judges
will probably get a compilation-linking error in your program.
Output corresponds exactly to the provided sample output format, including (mis)spelling and spacing. Mul-
tiple spaces will not be used in any of the judges output, except where explicitly stated.
Your solution to any problem should be submitted for judging using PC
2
software only. Once you have
submitted a solution, it will reach the judges. The time it takes for your problem to be judged will depend
on how busy the judges are. Once your submission has been judged, you will receive a message through PC
2
indicating the judgment. If your solution is accepted the message will be Yes, if it is not then the message
will be No, along with the type of error the judges encountered, which may be: Compilation Error,
Run-time Error, Time-limit Exceeded, Wrong Answer, Excessive Output, Incomplete Output or
Output Format Error.
Programming style is not considered in this contest. The judges will only test whether the input / output
behavior of your program is correct or not. However, each problem has an execution time-limit of 60 seconds.
That is, if your program takes more than 60 seconds to execute for the given input, it will be judged as
incorrect.
Contestants may bring any printed materials (books, papers, documentation, source code of programs, etc.)
to the contest area, but no soft copy will be allowed (diskettes, CDs, DVDs, pen-drives, etc.).
1
1 Days of our lives
Source le name: days.c, days.cpp or days.java
Have you ever wondered how many days have gone since you were born? or have you ever wondered how many
days will you spend on a trip?
Well then, if you havent asked yourself, someone has, therefore, you are now hired to develop a software ca-
pable of calculating precisely how many days exists between two given dates, including the end date.
You must remember that the leap years calculate as follows: any year divisible by 4 except centenary years not
divisible by 400
1.1 Input Format
The input will consist of several test cases, each of them specied will contain in a single line two valid dates, with
the format DD MM YYYY, where DD means the day, MM means the month, and YYYY the year.
The input must be read from standard input.
1.2 Output Format
For each case, output the total number of days.
The output must be written to standard output.
1.3 Sample Input
1 31 12 1983 09 07 2011
2 22 04 1985 23 04 1985
1.4 Output for the Sample Input
1 10053
2 2
2
2 < Tag > Tag <\ Tag >
Source le name: tag.c, tag.cpp or tag.java
All the areas of Computer Science use certain language or expressions to formalize ideas, concepts or even routines.
For example, Web Programming usually uses the HTML to create the websites, this Language is based on tags to
interpret the sentences and actions.
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analysing a
sequence of tokens to determine their grammatical structure with respect to a given (more or less) formal grammar.
Parsing is also an earlier term for the diagramming of sentences of natural languages, and is still used for the
diagramming of inected languages, such as the Romance languages or Latin. The term parsing comes from Latin
pars ( or ati onis), meaning part (of speech).
The problem is to develop a lexical interpreter to create an agenda. It means that you must check several tags, to
discard most of them, and store only the information that you need.
The agenda must contain: Full Name, Phone Number and Email. The tags are < name ><\ name >, < phone
><\ phone > and < email ><\ email >, respectively. For example, lets suppose the following data: < name
> Pedro Rodriguez <\ name> < phone > (0241)5555555 <\ phone > < email > maraton.uc@gmail.com <\ email>.
In the agenda it will be stored as follow:
Name: Pedro Rodriguez (Will always have name and lastname)
Phone Number: (0241)5555555 (Wont have any blank spaces)
Email: maraton.uc@gmail.com (Wont have any blank spaces)
The Rules are: Theres a blank space between the tag and the phrase, The phrases inside the tags have no format
at all. If the tags are dierent of the mentioned ones, must be discarded its content. Its considered invalid an
open tag followed by another open tag.
2.1 Input Format
The input begins with an integer n (2 n 1000) on a line by itself representing the number of persons that you
must found in the entire tagged document. Then you must scan the whole document searching for the n persons.
You may assume that all the valid tags are correct, none of them are incomplete.
The input must be read from standard input.
2.2 Output Format
The output consists in n blocks of data. That will have the following schema:
Name:
Phone Number:
Email:
Each line followed by the data, as it showed in the tagged document.
The output must be written to standard output.
3
2.3 Sample Input
1 2
2 <html> <body> <p> <a href="lastpage.htm"> This text</a> is a link to a page on this Web
3 site. </p>
4 <p> <a href="http://www.microsoft.com/"> This text</a> is a link to a page on the World
5 Wide Web. </p> </body> </html> <name> Crazy woman <\name> This text</a> <phone>
6 000000000-0505000 <\phone> <a href="nextpage.htm"> <email> crazy@woman.com <\email>
7 <email> asdasd@microsoft.com <\email>
8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
9 <HTML> <HEAD> <name> The Kinks <\name> <TITLE>Test Page</TITLE>
10 </HEAD> <BODY BACKGROUND="/usr/BILL/htmlbook/working/ch19/
11 lgreentile.gif" TEXT="Navy" LINK="Olive" VLINK="#999933" ALINK="Silver"> <TABLE
12 BORDER=0 CELLSPACING=8 CELLPADDING=5 VALIGN="TOP" BGCOLOR="#CCFF99" WIDTH=350>
13 <TR> <TD>Something here</TD> <phone> 92349234934 <\phone> <TD>Something Else</TD> </TR>
14 <TR> <TD>Something New</TD> <TD>Something Blue</TD> </TR> <TR> <email> dont have <\email>
15 <TD>Other things</TD> <TD>Things X, Y, and Z</TD> </TR> <TR>
16 <TD>The Cat in the Hat</TD> <TD>Dr Seuss Toothbrush</TD> </TR>
17 </TABLE> <P> Heres a paragraph created in Home Site.
18 It has <B>bold and <I>italic text in it.</I></B></P>
2.4 Output for the Sample Input
1 Name: Crazy Woman
2 Phone Number: 000000000-0505000
3 Email: crazy@woman.com
4
5 Name: The Kinks
6 Phone Number: 92349234934
7 Email: dont have
4
3 South Africa 2010
Source le name: south.c, south.cpp or south.java
When the rst round of the Soccer World Championship in France was coming to an end. 16 countries were
remaining then, among which the winner is determined by the following tournament:
1 Brazil -----+
+-- ? --+
2 Chile ------+ |
+-- ? --+
3 Nigeria ----+ | |
+-- ? --+ |
4 Denmark ----+ |
+-- ? --+
5 Holland ----+ | |
+-- ? --+ | |
6 Yugoslavia -+ | | |
+-- ? --+ |
7 Argentina --+ | |
+-- ? --+ |
8 England ----+ |
+-- World Champion
9 Italy ------+ |
+-- ? --+ |
10 Norway -----+ | |
+-- ? --+ |
11 France -----+ | | |
+-- ? --+ | |
12 Paraguay ---+ | |
+-- ? --+
13 Germany ----+ |
+-- ? --+ |
14 Mexico -----+ | |
+-- ? --+
15 Romania ----+ |
+-- ? --+
16 Croatia ----+
For each possible match A vs. B between these 16 nations, you are given the probability that team A wins
against B. This (together with the tournament mode displayed above) is sucient to compute the probability that a
given nation wins the World Cup. For example, if Germany wins against Mexico with 80%, Romania against Croatia
with 60%, Germany against Romania with 70% and Germany against Croatia with 90%, then the probability that
Germany reaches the semi-nals is 80%(70%60%+90%40%) = 62.4%. Your task is to write a program that
computes the chances of the 16 nations to become the World Champion 2010.
3.1 Input Format
The input le will contain just one test case. The rst 16 lines of the input le give the names of the 16 countries,
from top to bottom according to the picture given above.
Next, there will follow a 16 16 integer matrix P where element p
ij
gives the probability in percent that country
#i defeats country #j in a direct match. Country #i means the i-th country from top to bottom given in the list
of countries. In the picture above Brazil is #1 and Germany is #13, so p
1,13
= 55 would mean that in a match
between Brazil and Germany, Brazil wins with a probability of 55%. Note that matches may not end with a draw,
i.e. p
ij
+ p
ji
= 100 for all i, j. The input must be read from standard input.
3.2 Output Format
Output 16 lines of the form XXXXXXXXXX p = Y.Y Y %, where XXXXXXXXXX is the countrys name,
left-justied in a eld of 10 characters, and Y.Y Y is their chance in percent to win the cup, written to two decimal
5
places. Use the same order of countries like in the input le. The output must be written to standard output.
3.3 Sample Input
1 Brazil
2 Chile
3 Nigeria
4 Denmark
5 Holland
6 Yugoslavia
7 Argentina
8 England
9 Italy
10 Norway
11 France
12 Paraguay
13 Germany
14 Mexico
15 Romania
16 Croatia
17 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
18 35 50 35 45 40 35 35 50 30 40 25 40 25 40 35 35
19 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
20 40 55 40 50 45 40 40 55 35 45 30 45 30 45 40 40
21 45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
22 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
23 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
24 35 50 35 45 40 35 35 50 30 40 25 40 25 40 35 35
25 55 70 55 65 60 55 55 70 50 60 45 60 45 60 55 55
26 45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
27 60 75 60 70 65 60 60 75 55 65 50 65 50 65 60 60
28 45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
29 60 75 60 70 65 60 60 75 55 65 50 65 50 65 60 60
30 45 60 45 55 50 45 45 60 40 50 35 50 35 50 45 45
31 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
32 50 65 50 60 55 50 50 65 45 55 40 55 40 55 50 50
3.4 Output for the Sample Input
1 Brazil p=8.54%
2 Chile p=1.60%
3 Nigeria p=8.06%
4 Denmark p=2.79%
5 Holland p=4.51%
6 Yugoslavia p=7.50%
7 Argentina p=8.38%
8 England p=1.56%
9 Italy p=9.05%
10 Norway p=3.23%
11 France p=13.72%
12 Paraguay p=3.09%
13 Germany p=13.79%
14 Mexico p=3.11%
15 Romania p=5.53%
16 Croatia p=5.53%
6
4 Lets Gossip It!
Source le name: gossip.c, gossip.cpp or gossip.java
In the Gossipland, Gossip is a social network very used. It has its own codes to use it, and because of that, so
many people dont like it. But we dont want to use it, we want to obtain some information from this interesting
and complicated social network. It uses a lot of concepts described below:
Nickname: Every user has a unique nickname to be identied into the gossip world.
Gossip: Each status update is called a gossip. Every user can make status update every time he wants.
Reply: Every user can make a reply to another user, using $ followed by the nickname at the beginning of a gossip.
Mention: Every user can make a mention of another user about something, like a reply, but putting the $ followed
by the nickname in the middle of the gossip.
Hashtag: To make the topics search easier, they uses the hashtags to mention some specic topic, using a &
followed by the topic without spaces or special characters like dot, period, etc.
Trending Topic: The most used hashtags become the trending topics.
A gossip may contains the characters of the alphabet (from a to z and from A to Z) and the following punctuation
marks: ,, ., , ;, : and - (without single quotes).
Each word contains at most one special character ( $ or & ) and this will be in the begin on the word. The words
are separated by a single blank space or by a punctuation mark (dened above). For example:
[Nickname] user1
[Gossip] user1: I love programming contests!!!
[Reply] user2: $user1 me too!!!
[Mention] user2: I love programming contests!!! And $user1 love them too!!!
[Hashtag] user1: I love &programmingcontests
[Trending] Topic: &programmingcontests
Your task is given a set of gossips, calculate the user that has more replies, the user that have more mentions.
If theres a tie, you must show all the results.
4.1 Input Format
The input contains several test cases. The rst line contains a number t representing the number of gossips to be
analysed. The next t lines contain a gossip each one in the next format: Nickname: content of the gossip.
The input ends with t = 0. The input must be read from standard input.
4.2 Output Format
The output is three lines for each test case in the following format:
Most replied: $nickname
Most mentioned: $nickname
Trending Topic: &trendingtopic
The output must be written to standard output.
4.3 Sample Input
1 5
2 user1: I love &programmingcontests !!!
3 user2: $user1 me too!!!
4 user3: $user1 I love them too!
5 user1: I love &programmingcontests $user2 and $user3 love them too!
6 user1: We love &programmingcontests
7 0
4.4 Output for the Sample Input
1 Most replied: $user1
2 Most mentioned: $user2 $user3
3 Trending Topic: &programmingcontests
7

Vous aimerez peut-être aussi