COCI '06 Contest 5 #3 Tenis

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type

After Borko's second plan of taking over the village fell through (because Mirko's brother Stanko drank all the water), young Zvonko decided to relax with sports. For this purpose he stocked up on carrot juice and peanuts, and dived onto the couch, ready to watch the next tennis match on television.

While the two players are warming up, their statistics pop up on the screen. Zvonko noticed that the match history of the players contained invalid results. He had a brilliant idea where you write him a program that checks the validity of results, which he will then sell to the record keepers and enjoy a leisurely life.

A tennis match consists of sets, each set consisting of games. The following rules apply:

  • A player wins a set if he has 6 or more games and at least two games more than his opponent.
  • Additionally, if the result is 6:6 in the first or second set (but not the third set), a single final game is played to determine the winner of the set (the tie-break game).
  • The match ends when either player has won 2 sets. That player is the winner.

A match result is valid if a match could have been played by the above rules and ended in the result.

Additionally, if one of the players is Roger Federer (designated as federer in the input), then a result in which he has lost a set can't be valid (Zvonko knows Federer is from outer space).

Write a program that checks the validity of all matches between two players.

Input Specification

The first line of input contains the names of the two players separated by a single space. Both names will be strings of at most 20 lowercase letters of the English alphabet. The names will be different.

The second line contains an integer N (1 \le N \le 50), how many matches the two players have played.

Each of the following N lines contains the result of a single match, composed of the results of a number of sets separated by single spaces. Each match result contains between 1 and 5 sets.

A set is given in the format A:B, where A and B are games won by each player. These numbers will be integers between 0 and 99 (inclusive).

Output Specification

For each match, in the order they're given in the input, output da if the result is valid, or ne if it isn't.

Sample Input 1

sampras agassi
6
6:2 6:4
3:6 7:5 2:6
6:5 7:4
7:6 7:6
6:2 3:6
6:2 1:6 6:8

Sample Output 1

da
da
ne
da
ne
da

Sample Input 2

federer roddick
1
2:6 4:6

Sample Output 2

ne

Comments


  • 1
    a_sad_javamain  commented on Dec. 25, 2020, 4:20 a.m.

    Why is the result for the 4th match in the first sample case "da"? If the score was "7:6" in both sets, then wouldn't neither player have won each set ("A player wins a set if he has 6 or more games and at least two games more than his opponent")? It seems to me that the result of the match is indeterminate which means that the output would be "ne".


    • 2
      BalintR  commented on Dec. 25, 2020, 4:06 p.m.

      Read the rules more carefully:

      Additionally, if the result is 6:6 in the first or second set (but not the third set), a single final game is played to determine the winner of the set (the tie-break game).


      • 1
        a_sad_javamain  commented on Dec. 25, 2020, 5:35 p.m. edited

        But the result is 7:6 not 6:6 ...


        • 2
          BalintR  commented on Dec. 25, 2020, 5:52 p.m.

          The result was 6:6, then they played a tie-breaking game which upped the result to 7:6


          • 1
            a_sad_javamain  commented on Dec. 25, 2020, 6:07 p.m.

            Ok I get it now. Thanks!


  • 1
    Mike_Maty  commented on April 10, 2017, 2:26 p.m.

    Hey, I don't know Croatian. Please help!?


  • -15
    manamperineraj  commented on April 7, 2017, 2:00 p.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -11
      marshmelllo  commented on April 7, 2017, 2:35 p.m. edited

      This comment is hidden due to too much negative feedback. Show it anyway.


      • 11
        AndrewVII  commented on April 8, 2017, 6:45 p.m.

        I, too, agree. The faults in spelling are beyond unacceptable!


        • -5
          marshmelllo  commented on April 8, 2017, 5:56 p.m.

          This comment is hidden due to too much negative feedback. Show it anyway.


          • 5
            Phoenix1369  commented on April 9, 2017, 8:06 p.m.

            The statements themselves are in English though, and all COCI problems maintain their Croatian titles. In your case, we should replace every instance of handsome in coci14c5p4 with zgodan.


            • -7
              marshmelllo  commented on April 9, 2017, 11:58 p.m.

              This comment is hidden due to too much negative feedback. Show it anyway.


              • 10
                Kirito  commented on April 10, 2017, 1:45 a.m.

                Or we can translate it into Croatian. Just for you.