Connection Status:
Competition Arena > LongWordsDiv2
SRM 618 · 2013-12-22 · by ltaravilse · Simple Search, Iteration, String Manipulation
Class Name: LongWordsDiv2
Return Type: String
Method Name: find
Arg Types: (string)
Problem Statement

Problem Statement

Fox Ciel likes all the words that have the following properties:
  1. Each letter of the word is an uppercase English letter.
  2. Equal letters are never consecutive.
  3. There is no subsequence of the form xyxy, where x and y are (not necessarily distinct) letters. Note that a subsequence doesn't have to be contiguous.
Examples:
  • Ciel does not like "ABBA" because there are two consecutive 'B's.
  • Ciel does not like "THETOPCODER" because it contains the subsequence "TETE".
  • Ciel does not like "ABACADA" because it contains the subsequence "AAAA". (Note that here x=y='A'.)
  • Ciel likes "A", "ABA", and also "ABCBA".
Given a String word, return "Likes" (quotes for clarity) if Ciel likes word and "Dislikes" if she does not.

Constraints

  • word will contain between 1 and 100 characters, inclusive.
  • Each character of word will be an uppercase English letter ('A'-'Z').
Examples
0)
"AAA"
Returns: "Dislikes"
1)
"ABCBA"
Returns: "Likes"
2)
"ABCBAC"
Returns: "Dislikes"
3)
"TOPCODER"
Returns: "Likes"
4)
"VAMOSGIMNASIA"
Returns: "Dislikes"

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

Coding Area

Language: C++17 · define a public class LongWordsDiv2 with a public method string find(string word) · 71 test cases · 2 s / 256 MB per case

Submitting as anonymous