PikachuEasy
SRM 533 · 2011-11-22 · by cgy4ever
SRM 533 · 2011-11-22 · by cgy4ever · String Parsing
Problem Statement
Problem Statement
Pikachu is a well-known character in the Pokemon anime series.
Pikachu can speak, but only 3 syllables: "pi", "ka", and "chu".
Therefore Pikachu can only pronounce strings that can be created as a concatenation of one or more syllables he can pronounce. For example, he can pronounce the words "pikapi" and "pikachu".
You are given aString word.
Your task is to check whether Pikachu can pronounce the string. If the string can be produced by concatenating copies of the strings "pi", "ka", and "chu", return "YES" (quotes for clarity). Otherwise, return "NO".
You are given a
Constraints
- word will contain between 1 and 50 characters, inclusive.
- Each character of word will be a lowercase letter ('a'-'z').
Examples
0)
"pikapi" Returns: "YES"
"pikapi" = "pi" + "ka" + "pi", so Pikachu can say it.
1)
"pipikachu" Returns: "YES"
This time we have "pipikachu" = "pi" + "pi" + "ka" + "chu", so Pikachu can say it as well.
2)
"pikaqiu" Returns: "NO"
Pikachu can't say "pikaqiu" since 'q' does not appear in "pi", "ka", or "chu".
3)
"topcoder" Returns: "NO"
4)
"piika" Returns: "NO"
Submissions are judged against all 146 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class PikachuEasy with a public method string check(string word) · 146 test cases · 2 s / 256 MB per case