Role classification P60296


Statement
 

pdf   zip

thehtml

Simulate a server of a role-playing game for two players. Each player has an “elo”, which is a value larger the better is the player. Everyone starts with 1200 points, and nobody ever gets a lower quantity, no matter how many games are lost. Whenever there is a match, the winner gets 10 elo points, and the loser loses 10 elo points (with the limitation above). The elo of a player is kept when he or she disconnects from the server.

We have these instructions:

  • LOGINj : The player j starts a session. Ignore it if the player is already connected.
  • LOGOUTj : The player j closes the session. Ignore it if the player is not connected.
  • PLAYj1 ⁠ ⁠ j2 : Indicates that j1 has beaten j2, with j1j2. Ignore it but print an error message if any of the two players is not connected.
  • GET_ELOj : Print the player j (who was connected for sure previously, although now may be disconnected) with his or her current elo.

Input

Input consists of several instructions for at most 105 players. Each player’s name is different and made up of only lowercase letters.

Output

For every instruction “GET_ELO” (and perhaps “PLAY”) print the proper output. At the end, print an empty line, the word “RANKING”, and a ranking sorted in decreasing order by elo (if there is a tie, print first the alfabetically smallest name) with all the players ever connected to the server.

Public test cases
  • Input

    LOGIN destello
    LOGIN fxtr
    PLAY destello fxtr
    PLAY destello fxtr
    LOGIN carokhan
    GET_ELO destello
    GET_ELO fxtr
    LOGOUT destello
    PLAY carokhan fxtr
    LOGOUT fxtr
    LOGIN cerebrus
    LOGOUT cerebrus
    LOGIN grassman
    PLAY destello grassman
    PLAY grassman destello
    LOGIN cusell
    

    Output

    destello 1220
    fxtr 1200
    player(s) not connected
    player(s) not connected
    
    RANKING
    destello 1220
    carokhan 1210
    cerebrus 1200
    cusell 1200
    fxtr 1200
    grassman 1200
    
  • Input

    PLAY omer petit
    LOGIN omer
    PLAY omer petit
    LOGIN omer
    LOGOUT omer
    GET_ELO omer
    

    Output

    player(s) not connected
    player(s) not connected
    omer 1200
    
    RANKING
    omer 1200
    
  • Information
    Author
    Enric Cusell
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python