14619 - Naming Convention 2   

Description

In computer programming, naming conventions improve the readability of code by providing consistent rules for naming identifiers. This problem focuses on converting variable names from kebab-case to either camel-case or snake-case, depending on a given instruction.

  • Kebab-case: Words are separated by hyphens (-).
    Example: an-example-of-variable-name.

  • Camel-case: The first letter of each word is capitalized and no separators are used.
    For instance, the kebab-case an-example-of-variable-name becomes AnExampleOfVariableName.

  • Snake-case: Words are joined using underscores (_).
    For instance, the kebab-case an-example-of-variable-name becomes an_example_of_variable_name.

You are given a list of variables in kebab-case along with the creation time $t_i$ and a flag $o_i$ indicating the target naming convention:

  • $o_i = 0$ for converting to camel-case.
  • $o_i = 1$ for converting to snake-case.

Your tasks are:

  1. Implement the constructors of the CamelCase and SnakeCase classes so that they convert the given kebab-case variable name into the corresponding naming convention.
  2. Implement the destructors for the base class Case and its derived classes, CamelCase and SnakeCase. When a variable is deleted, the destructor should print:
    • For a camel-case instance:
      Camel-case variable <VarName> created at time <CreateTime> is deleted
    • For a snake-case instance:
      Snake-case variable <VarName> created at time <CreateTime> is deleted

Here <VarName> is the converted variable name and <CreateTime> is the time when the variable was created.

Input

The first line contains an integer $N$, representing the total number of variables.

Each of the following $N$ lines contains:

  • A string $S_i$, the variable name in kebab-case, containing only hypthens and lowercase letters.
  • An integer $t_i$, the time when the variable is created.
  • An integer $o_i$, which indicates the target naming convention (0 for camel-case, 1 for snake-case).

Constraints

  • $1 \leq N \leq 12$
  • $S_i$ is a valid kebab-case variable name.
  • $1 \leq |S_i| \leq 100$
  • $o_i \in {0, 1}$

Output

For each variable, when the object is deleted, output exactly one line:

  • If the variable has been converted to camel-case, output:
    Camel-case variable <VarName> created at time <CreateTime> is deleted
  • If the variable has been converted to snake-case, output:
    Snake-case variable <VarName> created at time <CreateTime> is deleted

Sample Input  Download

Sample Output  Download

Partial Judge Code

14619.cpp

Partial Judge Header

14619.h

Tags




Discuss