TopcoderArchiveVisit Topcoder
SRM22 Dec 2013
SRM 613

TaroString

Problem statement, definition, constraints, and public examples.

Problem Statement

Cat Taro has a string S. He wants to obtain the string "CAT" from the string S. In a single turn he can choose any character and erase all occurrences of this character in S. He can do as many turns as he wants (possibly zero).

You are given the String S. Return "Possible" (quotes for clarity) if it is possible to obtain the string "CAT" and "Impossible" otherwise.

Definition

Class:
TaroString
Method:
getAnswer
Parameters:
String
Returns:
String
Method signature:
String getAnswer(String S)
(be sure your method is public)

Constraints

  • S will contain between 1 and 50 characters, inclusive.
  • S will contain only uppercase English letters ('A'-'Z').

Examples

  1. "XCYAZTX"
    Returns: "Possible"
    It is possible to obtain string "CAT" in three turns, as follows: Erase all characters 'X' (and obtain the string "CYAZT") Erase all characters 'Y' (and obtain the string "CAZT") Erase all characters 'Z' (and obtain the string "CAT")
  2. "CTA"
    Returns: "Impossible"
  3. "ACBBAT"
    Returns: "Impossible"
    Note that whenever you are erasing a character, you must erase all its occurrences. In this case, it is not possible to erase the first 'A' and keep the second one.
  4. "SGHDJHFIOPUFUHCHIOJBHAUINUIT"
    Returns: "Possible"
  5. "CCCATT"
    Returns: "Impossible"
Back to all problems