Connection Status:
Competition Arena > FoxAndHandleEasy
SRM 563 · 2012-06-05 · by cgy4ever · Simple Search, Iteration, Simulation
Class Name: FoxAndHandleEasy
Return Type: String
Method Name: isPossible
Arg Types: (string, string)
Problem Statement

Problem Statement

Fox Ciel has a new favorite string operation that works as follows: She takes two copies of some string X, and inserts one copy somewhere into the other copy of the same string. (She can also insert it at the beginning or, equivalently, at the end.) This operation is called expansion of the string X. For example, if X = "Ciel", she can expand it to "CielCiel", "CCieliel", "CiCielel", or "CieCiell".


You are given two Strings: S and T. Return "Yes" (quotes for clarity) if T can be obtained by expanding S exactly once. Otherwise, return "No".

Constraints

  • S will contain between 1 and 50 characters, inclusive.
  • T will contain between 1 and 50 characters, inclusive.
  • Both S and T will contain uppercase and lowercase letters only ('A'-'Z' and 'a'-'z').
Examples
0)
"Ciel"
"CieCiell"
Returns: "Yes"

She can insert "Ciel" between "Cie" and "l".

1)
"Ciel"
"FoxCiel"
Returns: "No"

Each string obtained by expanding S="Ciel" has exactly 8 letters.

2)
"FoxCiel"
"FoxFoxCielCiel"
Returns: "Yes"
3)
"FoxCiel"
"FoxCielCielFox"
Returns: "No"
4)
"Ha"
"HaHaHaHa"
Returns: "No"

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

Coding Area

Language: C++17 · define a public class FoxAndHandleEasy with a public method string isPossible(string S, string T) · 150 test cases · 2 s / 256 MB per case

Submitting as anonymous