Connection Status:
Competition Arena > TaroString
SRM 613 · 2013-12-22 · by Witaliy · String Manipulation
Class Name: TaroString
Return Type: String
Method Name: getAnswer
Arg Types: (string)
Problem Statement

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.

Constraints

  • S will contain between 1 and 50 characters, inclusive.
  • S will contain only uppercase English letters ('A'-'Z').
Examples
0)
"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")

1)
"CTA"
Returns: "Impossible"
2)
"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.

3)
"SGHDJHFIOPUFUHCHIOJBHAUINUIT"
Returns: "Possible"
4)
"CCCATT"
Returns: "Impossible"

Submissions are judged against all 96 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class TaroString with a public method string getAnswer(string S) · 96 test cases · 2 s / 256 MB per case

Submitting as anonymous