Results 1 to 4 of 4

Thread: Need help

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Need help

    PROBLEM STATEMENT

    amhcxa is a TopCoder member and he just entered a room for a single round match 98. He knows everybody in the room. He also knows the programming language each person in the room uses. amhcxa himself programs equally bad in Java or C++. Namely, he often submits incorrect code. He wants to pick a programming language for today's match to minimize the number of people in the room who would read his code during the challenge phase (he doesn't want to give people an extra opportunity to get challenge points).

    In more detail:
    - He knows that everybody starts reading source code from the bottom of the room up (that means everybody hopes that the weakest person in the room has the biggest probability of making a mistake)
    - He knows that everybody will submit something
    - He knows that everybody reads source code only if it is written in the same programming language as they use to code themselves, otherwise they skip it
    - He knows that everybody spends exactly five minutes reading a single person's code.
    - He knows that the challenge phase takes exactly 15 minutes (that is, each person has time to read the code of exactly three people).
    - He knows that people do not examine their own code

    COMMENT
    This problem was created before C# was allowed at TopCoder. Assume no one in the room codes in C#.

    Your task is, given a list of how programming languages are distributed in the room from top to bottom and the place where amhcxa fits in the list, return a string formatted "<language> <n>/<m>", where <language> represents "Java", "C++" or "Whatever"; <n> represents how many people will check amhcxa's code if he chooses Java and <m> represents how many people will check his code if he chooses C++. <language> should be "Java" when <n> is less than <m>, "C++" when <n> is more than <m>, and "Whatever" when <m> is equal to <n>. Between <language> and <n> should be exactly one space (and there should not be other spaces than that), between <n> and <m> should be the character '/'.

    DEFINITION
    Class: Language
    Method: choose
    Parameters: vector<string>
    Returns: string
    Method signature (be sure your method is public): string choose(vector<string> languages);

    TopCoder will ensure the validity of the inputs. Inputs are valid if all of the following criteria are met:
    - languages will contain between 8 to 10 elements inclusive
    - each element of languages is one of: "Java", "C++", "amhcxa"
    - exactly one element of languages equals "amhcxa"

    NOTE
    languages is sorted in descending order with respect to rating: the first element of languages is the language used by the highest ranked player in the room, the second element of languages is the language used by the second-highest ranked player in the room etc. That is, competitors would start checking code from the last element of the languages.

    EXAMPLES
    1. languages = {"amhcxa", "Java", "Java", "Java", "Java", "C++", "C++", "C++", "C++"} return "Whatever 0/0" as nobody would have time to read amhcxa's code.

    2. languages = {"amhcxa", "Java", "Java", "Java", "Java", "Java", "Java", "Java", "C++", "C++"} return "Java 0/2".

    3. languages = {"C++", "Java", "Java", "Java", "Java", "Java", "Java", "C++", "amhcxa"} return "C++ 6/2".

    4. languages = {"Java", "Java", "Java", "Java", "amhcxa", "C++", "C++", "C++", "C++", "C++"} return "C++ 4/0".

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    So which part do you need help with?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    hehe, all of them.

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    well we're not going to do it for you ...which do you want to try first?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width