Estudiants que s'inscriuen en assignatures X90041


Statement
 

pdf   zip

thehtml

Heu d’implementar un programa que manega estudiants, assignatures, i quins estudiants estan inscrits en quines assignatures.

L’entrada consistirà en una llista de comandes. Entre elles, hi ha comandes que matriculen un estudiant en una assignatura. Per exemple:

ENROLL maria.lapuente Algebra
ENROLL maria.lapuente OperatingSystems
ENROLL john.smith Programming
ENROLL nuria.margalef Calculus
ENROLL laura.venture Algebra
ENROLL maria.lapuente Calculus
ENROLL laura.venture Programming
ENROLL maria.lapuente Programming
ENROLL nuria.margalef Programming

També hi ha comandes que donen de baixa un estudiant en una assignatura. Per exemple:

QUIT maria.lapuente Programming
QUIT laura.venture Algebra

També hi ha comandes que demanen la llista d’assignatures, en ordre lexicogràfic, en les quals un estudiant donat està matriculat. Per exemple:

SUBJECTSOFSTUDENT maria.lapuente
SUBJECTSOFSTUDENT john.smith
SUBJECTSOFSTUDENT nuria.margalef

Incloent les comandes prèvies de matricular i donar de baixa, la sortida seria aquesta:

Algebra Calculus OperatingSystems
Programming
Calculus Programming

També hi ha comandes que demanen la llista de persones, en ordre lexicogràfic, que estan matriculades en una assignatura. Per exemple:

STUDENTSOFSUBJECT Algebra
STUDENTSOFSUBJECT Calculus
STUDENTSOFSUBJECT Programming

Incloent les comandes prèvies de matricular i donar de baixa, la sortida seria aquesta:

maria.lapuente
maria.lapuente nuria.margalef
john.smith laura.venture nuria.margalef

Observació: Podeu seguir l’enfoc que considereu oportú, i podeu utilitzar qualsevol de les classes presentades al curs (string, vector, stack, queue, list, map, set) de la manera que considereu oportuna. Però tingueu en compte que la vostra elecció pot afectar a l’eficiència de la vostra solució, i per tant al fet de poder superar tots els jocs de proves o només els públics (cosa que us deixarà amb la meitat de la nota).

Entrada

Cada linia de l’entrada consisteix en una instrucció del següent tipus, a on student i subject es poden llegir com strings no buits qualsevols, i tenen menys de 20 caràcters:

  • ENROLL student subject
  • QUIT student subject
  • SUBJECTSOFSTUDENT student
  • STUDENTSOFSUBJECT subject

Podem suposar que les entrades son correctes: mai s’afegeix un estudiant a una assignatura si ja hi és, i mai es dona de baixa un estudiant d’una assignatura si no hi és.

Sortida

Per a cada instrucció SUBJECTSOFSTUDENT student, s’escriurà una línia per la sortida amb la llista d’assignatures actuals de l’estudiant, separada per espais en blanc.

Per a cada instrucció STUDENTSOFSUBJECT subject, s’escriurà una línia per la sortida amb la llista d’estudiants actuals de l’assignatura, ordenada lexicogràficament, i separada per espais en blanc.

Observació

Avaluació sobre 10 punts:

  • Solució lenta: 5 punts.
  • solució ràpida: 10 punts.

Entenem com a solució ràpida una que és correcta, de cost nlog(n) o inferior, i capaç de superar els jocs de proves públics i privats. Entenem com a solució lenta una que no és ràpida, però és correcta i capaç de superar els jocs de proves públics.

Public test cases
  • Input

    ENROLL merce.nice Programming
    STUDENTSOFSUBJECT Programming
    ENROLL manel.rueda Compilers
    ENROLL joel.cabas Projects
    ENROLL nuria.margalef Hardware
    ENROLL joel.cabas Compilers
    SUBJECTSOFSTUDENT manel.rueda
    ENROLL nuria.margalef Programming
    ENROLL sandra.rain Physics
    ENROLL angels.herrero Projects
    STUDENTSOFSUBJECT Projects
    STUDENTSOFSUBJECT Algebra
    STUDENTSOFSUBJECT Programming
    ENROLL laura.venture Hardware
    QUIT sandra.rain Physics
    ENROLL jose.mola Hardware
    ENROLL merce.nice Algebra
    SUBJECTSOFSTUDENT laura.venture
    SUBJECTSOFSTUDENT nuria.margalef
    ENROLL manel.rueda Calculus
    ENROLL laura.venture Compilers
    SUBJECTSOFSTUDENT joel.cabas
    STUDENTSOFSUBJECT Projects
    ENROLL jose.mola Projects
    STUDENTSOFSUBJECT Algebra
    STUDENTSOFSUBJECT Physics
    SUBJECTSOFSTUDENT laura.venture
    STUDENTSOFSUBJECT Hardware
    ENROLL joel.cabas Calculus
    STUDENTSOFSUBJECT Compilers
    QUIT manel.rueda Calculus
    SUBJECTSOFSTUDENT nuria.margalef
    ENROLL laura.venture Physics
    ENROLL joel.cabas Hardware
    ENROLL sandra.rain Physics
    STUDENTSOFSUBJECT Compilers
    QUIT joel.cabas Calculus
    ENROLL laura.venture Projects
    ENROLL joel.cabas Calculus
    ENROLL angels.herrero Algebra
    SUBJECTSOFSTUDENT joel.cabas
    ENROLL jose.mola Algebra
    QUIT sandra.rain Physics
    QUIT jose.mola Hardware
    SUBJECTSOFSTUDENT angels.herrero
    SUBJECTSOFSTUDENT jose.mola
    ENROLL joel.cabas Programming
    ENROLL manel.rueda Algebra
    SUBJECTSOFSTUDENT nuria.margalef
    STUDENTSOFSUBJECT Physics
    ENROLL manel.rueda Projects
    ENROLL sandra.rain Projects
    ENROLL jose.mola Programming
    ENROLL manel.rueda Physics
    ENROLL merce.nice Projects
    ENROLL laura.venture Programming
    ENROLL manel.rueda Calculus
    ENROLL merce.nice Calculus
    ENROLL sandra.rain Calculus
    QUIT nuria.margalef Hardware
    ENROLL manel.rueda Hardware
    QUIT laura.venture Compilers
    STUDENTSOFSUBJECT Calculus
    SUBJECTSOFSTUDENT angels.herrero
    ENROLL jose.mola Calculus
    ENROLL merce.nice Hardware
    ENROLL angels.herrero Compilers
    SUBJECTSOFSTUDENT laura.venture
    ENROLL sandra.rain Programming
    ENROLL angels.herrero Physics
    ENROLL nuria.margalef Projects
    SUBJECTSOFSTUDENT angels.herrero
    SUBJECTSOFSTUDENT laura.venture
    ENROLL joel.cabas Algebra
    SUBJECTSOFSTUDENT jose.mola
    STUDENTSOFSUBJECT Hardware
    STUDENTSOFSUBJECT Algebra
    SUBJECTSOFSTUDENT nuria.margalef
    STUDENTSOFSUBJECT Programming
    SUBJECTSOFSTUDENT laura.venture
    

    Output

    merce.nice
    Compilers
    angels.herrero joel.cabas
    
    merce.nice nuria.margalef
    Hardware
    Hardware Programming
    Compilers Projects
    angels.herrero joel.cabas
    merce.nice
    
    Compilers Hardware
    jose.mola laura.venture nuria.margalef
    joel.cabas laura.venture manel.rueda
    Hardware Programming
    joel.cabas laura.venture manel.rueda
    Calculus Compilers Hardware Projects
    Algebra Projects
    Algebra Projects
    Hardware Programming
    laura.venture
    joel.cabas manel.rueda merce.nice sandra.rain
    Algebra Projects
    Hardware Physics Programming Projects
    Algebra Compilers Physics Projects
    Hardware Physics Programming Projects
    Algebra Calculus Programming Projects
    joel.cabas laura.venture manel.rueda merce.nice
    angels.herrero joel.cabas jose.mola manel.rueda merce.nice
    Programming Projects
    joel.cabas jose.mola laura.venture merce.nice nuria.margalef sandra.rain
    Hardware Physics Programming Projects
    
  • Input

    SUBJECTSOFSTUDENT jose.mola
    ENROLL nuria.margalef Hardware
    ENROLL angels.herrero Programming
    SUBJECTSOFSTUDENT joel.cabas
    STUDENTSOFSUBJECT Hardware
    STUDENTSOFSUBJECT Algebra
    ENROLL jose.mola Physics
    STUDENTSOFSUBJECT Physics
    STUDENTSOFSUBJECT Hardware
    ENROLL laura.venture Algebra
    ENROLL nuria.margalef Algebra
    ENROLL laura.venture Compilers
    ENROLL joel.cabas Calculus
    STUDENTSOFSUBJECT Algebra
    ENROLL sandra.rain Programming
    STUDENTSOFSUBJECT Projects
    ENROLL jose.mola Hardware
    QUIT jose.mola Physics
    QUIT joel.cabas Calculus
    SUBJECTSOFSTUDENT angels.herrero
    SUBJECTSOFSTUDENT nuria.margalef
    SUBJECTSOFSTUDENT laura.venture
    SUBJECTSOFSTUDENT joel.cabas
    ENROLL laura.venture Hardware
    ENROLL sandra.rain Physics
    SUBJECTSOFSTUDENT manel.rueda
    STUDENTSOFSUBJECT Compilers
    ENROLL laura.venture Projects
    STUDENTSOFSUBJECT Programming
    STUDENTSOFSUBJECT Hardware
    ENROLL angels.herrero Algebra
    ENROLL joel.cabas Programming
    SUBJECTSOFSTUDENT sandra.rain
    SUBJECTSOFSTUDENT jose.mola
    ENROLL angels.herrero Hardware
    ENROLL jose.mola Projects
    ENROLL nuria.margalef Programming
    ENROLL nuria.margalef Projects
    ENROLL angels.herrero Projects
    ENROLL sandra.rain Projects
    STUDENTSOFSUBJECT Physics
    STUDENTSOFSUBJECT Algebra
    STUDENTSOFSUBJECT Physics
    ENROLL laura.venture Programming
    STUDENTSOFSUBJECT Programming
    ENROLL merce.nice Calculus
    STUDENTSOFSUBJECT Algebra
    QUIT nuria.margalef Hardware
    ENROLL manel.rueda Hardware
    QUIT laura.venture Compilers
    STUDENTSOFSUBJECT Programming
    ENROLL laura.venture Physics
    SUBJECTSOFSTUDENT angels.herrero
    SUBJECTSOFSTUDENT laura.venture
    QUIT sandra.rain Programming
    STUDENTSOFSUBJECT Programming
    STUDENTSOFSUBJECT Physics
    STUDENTSOFSUBJECT Physics
    STUDENTSOFSUBJECT Algebra
    QUIT nuria.margalef Programming
    STUDENTSOFSUBJECT Calculus
    QUIT jose.mola Projects
    QUIT angels.herrero Projects
    SUBJECTSOFSTUDENT jose.mola
    SUBJECTSOFSTUDENT jose.mola
    SUBJECTSOFSTUDENT merce.nice
    STUDENTSOFSUBJECT Algebra
    QUIT merce.nice Calculus
    STUDENTSOFSUBJECT Programming
    STUDENTSOFSUBJECT Hardware
    SUBJECTSOFSTUDENT nuria.margalef
    SUBJECTSOFSTUDENT manel.rueda
    SUBJECTSOFSTUDENT jose.mola
    ENROLL manel.rueda Programming
    ENROLL merce.nice Physics
    ENROLL jose.mola Physics
    STUDENTSOFSUBJECT Physics
    STUDENTSOFSUBJECT Algebra
    STUDENTSOFSUBJECT Physics
    SUBJECTSOFSTUDENT manel.rueda
    

    Output

    
    nuria.margalef
    
    jose.mola
    nuria.margalef
    laura.venture nuria.margalef
    
    Programming
    Algebra Hardware
    Algebra Compilers
    
    
    laura.venture
    angels.herrero sandra.rain
    jose.mola laura.venture nuria.margalef
    Physics Programming
    Hardware
    sandra.rain
    angels.herrero laura.venture nuria.margalef
    sandra.rain
    angels.herrero joel.cabas laura.venture nuria.margalef sandra.rain
    angels.herrero laura.venture nuria.margalef
    angels.herrero joel.cabas laura.venture nuria.margalef sandra.rain
    Algebra Hardware Programming Projects
    Algebra Hardware Physics Programming Projects
    angels.herrero joel.cabas laura.venture nuria.margalef
    laura.venture sandra.rain
    laura.venture sandra.rain
    angels.herrero laura.venture nuria.margalef
    merce.nice
    Hardware
    Hardware
    Calculus
    angels.herrero laura.venture nuria.margalef
    angels.herrero joel.cabas laura.venture
    angels.herrero jose.mola laura.venture manel.rueda
    Algebra Projects
    Hardware
    Hardware
    jose.mola laura.venture merce.nice sandra.rain
    angels.herrero laura.venture nuria.margalef
    jose.mola laura.venture merce.nice sandra.rain
    Hardware Programming
    
  • Information
    Author
    PRO2
    Language
    Catalan
    Official solutions
    Unknown. This problem is being checked.
    User solutions
    C++