Contenidors


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C#, Go, Java

Els contenidors són entorns d'execució aïllats que només tenen accés als recursos (cpu, memòria, sistema d'arxius, xarxa, etc.) que li són assignats.

Existeixen moltes solucions de software que permeten el maneig de contenidors (crear, iniciar, parar, eliminar...).

Una forma habitual de gestionar els contenidors és a través de comandaments. Per exemple, el comandament START inicia un contenidor, i STOP l'atura. És clar, que un contenidor ha d'estar un estat adequat per a poder enviar-li un comandament. Per exemple, no es pot aturar un contenidor que no estigui en execució.

El següent diagrama ilustra els estats en els que pot estar un contenidor, i els comandaments que es poden executar sobre ell, canviant el seu estat.

Es requereix crear un programa per a gestionar els estats d'un contenidor a través de comandaments.

Input Format

La entrada consisteix en un estat i un comandament.

Un contenidor que encara no existeix s'indica amb l'estat '_'

Constraints

estat = { _ | CREATED | RUNNING | PAUSED | STOPPED }

comandament = { CREATE | START | PAUSE | UNPAUSE | STOP | RM }

Output Format

S'indicarà l'estat en que ha de quedar el contenidor si el comandament es pot realitzar. Si no es pot realitzar, s'indicarà amb el missatge d'error "Invalid command for state "

Test Case 1

Input
_  CREATE
Output
CREATED

Test Case 2

Input
_  START
Output
Invalid command START for state _

Test Case 3

Input
_  PAUSE
Output
Invalid command PAUSE for state _

Test Case 4

Input
_  UNPAUSE
Output
Invalid command UNPAUSE for state _

Test Case 5

Input
_  STOP
Output
Invalid command STOP for state _

Test Case 6

Input
_  RM
Output
Invalid command RM for state _

Test Case 7

Input
CREATED  CREATE
Output
Invalid command CREATE for state CREATED

Test Case 8

Input
CREATED  START
Output
RUNNING

Test Case 9

Input
CREATED  PAUSE
Output
Invalid command PAUSE for state CREATED

Test Case 10

Input
CREATED  UNPAUSE
Output
Invalid command UNPAUSE for state CREATED

Test Case 11

Input
CREATED  STOP
Output
Invalid command STOP for state CREATED

Test Case 12

Input
CREATED  RM
Output
DELETED

Test Case 13

Input
RUNNING  CREATE
Output
Invalid command CREATE for state RUNNING

Test Case 14

Input
RUNNING  START
Output
Invalid command START for state RUNNING

Test Case 15

Input
RUNNING  PAUSE
Output
PAUSED

Test Case 16

Hidden: this is a private test case!

Test Case 17

Hidden: this is a private test case!

Test Case 18

Hidden: this is a private test case!

Test Case 19

Hidden: this is a private test case!

Test Case 20

Hidden: this is a private test case!

Test Case 21

Hidden: this is a private test case!

Test Case 22

Hidden: this is a private test case!

Test Case 23

Hidden: this is a private test case!

Test Case 24

Hidden: this is a private test case!

Test Case 25

Hidden: this is a private test case!

Test Case 26

Hidden: this is a private test case!

Test Case 27

Hidden: this is a private test case!

Test Case 28

Hidden: this is a private test case!

Test Case 29

Hidden: this is a private test case!

Test Case 30

Hidden: this is a private test case!


Authorship: Gerard Falcó

CC BY-NC-SA 4.0