anniversary session 2011

Upload: carlos-alberto-florio-luis

Post on 03-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Anniversary Session 2011

    1/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. Pleaseinform the Contest Staff immediately if something is missing from your problem set.

    Welcome to the Programming Contest and enjoy it!

  • 8/12/2019 Anniversary Session 2011

    2/8

    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 inputand write results to the standard output.

    You may use any of the following programming languages: C, C++ or Java. You may use different program-ming languages for different problems and even for different submissions of a problem.

    All problems have a source file name shown below the title of the problem. The extensions you must use foryour source files are: .cfor programs written in C, .cpp for those in C++, and .javafor those in Java.

    You may use any of the standard libraries that your chosen programming language provides. You may notuse any other library that requires an extra flag to be passed to the compiler command. If you do this, judgeswill 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 PC2 software only. Once you havesubmitted a solution, it will reach the judges. The time it takes for your problem to be judged will dependon 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 messagewill 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 orOutput Format Error.

    Programming style is not considered in this contest. The judges will only test whether the input / outputbehavior 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 asincorrect.

    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

  • 8/12/2019 Anniversary Session 2011

    3/8

    1 Days of our lives

    Source file name: days.c, days.cpp ordays.java

    Have you ever wondered how many days have gone since you were born? or have you ever wondered how manydays 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 notdivisible by 400

    1.1 Input Format

    The input will consist of several test cases, each of them specified will contain in a single line two valid dates, withthe 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

  • 8/12/2019 Anniversary Session 2011

    4/8

    2 < Tag > Tag

    Source file name: tag.c, tag.cpp ortag.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 tointerpret 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 thediagramming of inflected languages, such as the Romance languages or Latin. The term parsing comes from Latinpars (orationis), meaning part (of speech).

    The problem is to develop a lexical interpreter to create an agenda. It means that you must check several tags, todiscard 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 >, < phone> and < email >, respectively. For example, lets suppose the following data: < name>Pedro Rodriguez (0241)5555555 < email>[email protected].

    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: [email protected] (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 formatat all. If the tags are different of the mentioned ones, must be discarded its content. Its considered invalid anopen 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 youmust found in the entire tagged document. Then you must scan the whole document searching for thenpersons.

    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

  • 8/12/2019 Anniversary Session 2011

    5/8

    2.3 Sample Input

    1 2

    2

    This text is a link to a page on this Web

    3 site.

    4

    This text is a link to a page on the World

    5 Wide Web.

    Crazy woman This text

    6 000000000-0505000 [email protected]

    7 [email protected]

    8 9 The Kinks Test Page

    10

    13 Something here 92349234934 Something Else

    14 Something New Something Blue dont have

    15 Other things Things X, Y, and Z

    16 The Cat in the Hat Dr Seuss Toothbrush

    17

    Heres a paragraph created in Home Site.

    18 It has bold and italic text in it.

    2.4 Output for the Sample Input

    1 Name: Crazy Woman

    2 Phone Number: 000000000-0505000

    3 Email: [email protected]

    4

    5 Name: The Kinks

    6 Phone Number: 92349234934

    7 Email: dont have

    4

  • 8/12/2019 Anniversary Session 2011

    6/8

    3 South Africa 2010

    Source file name: south.c, south.cpp orsouth.java

    When the first round of the Soccer World Championship in France was coming to an end. 16 countries wereremaining 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 Champion9 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 winsagainst B. This (together with the tournament mode displayed above) is sufficient to compute the probability that agiven nation wins the World Cup. For example, if Germany wins against Mexico with 80%, Romania against Croatiawith 60%, Germany against Romania with 70% and Germany against Croatia with 90%, then the probability thatGermany reaches the semi-finals is 80% (70% 60%+90% 40%) = 62.4%. Your task is to write a program thatcomputes the chances of the 16 nations to become the World Champion 2010.

    3.1 Input Format

    The input file will contain just one test case. The first 16 lines of the input file 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 Pwhere element pij 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 listof countries. In the picture above Brazil is #1 and Germany is #13, so p1,13 = 55 would mean that in a matchbetween Brazil and Germany, Brazil wins with a probability of 55%. Note that matches may not end with a draw,i.e. pij+ pji = 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%, whereXXXXXXXXXXis the countrys name,left-justified in a field of 10 characters, and Y.Y Yis their chance in percent to win the cup, written to two decimal

    5

  • 8/12/2019 Anniversary Session 2011

    7/8

    places. Use the same order of countries like in the input file. 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 3519 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 5032 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

  • 8/12/2019 Anniversary Session 2011

    8/8

    4 Lets Gossip It!

    Source file name: gossip.c, gossip.cpp orgossip.java

    In the Gossipland, Gossip is a social network very used. It has its own codes to use it, and because of that, somany people dont like it. But we dont want to use it, we want to obtain some information from this interestingand complicated social network. It uses a lot of concepts described below:Nickname: Every user has a unique nickname to be identified 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 $ followedby the nickname in the middle of the gossip.Hashtag: To make the topics search easier, they uses the hashtags to mention some specific 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 punctuationmarks: ,, ., , ;, : and - (without single quotes).Each word contains at most one special character ( $ or & ) and this will be in the begin on the word. The wordsare separated by a single blank space or by a punctuation mark (defined 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 first line contains a number t representing the number of gossips to beanalysed. 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