Connection Status:
Competition Arena > AkariDaisukiDiv2
SRM 541 · 2011-11-22 · by semiexp · String Manipulation
Class Name: AkariDaisukiDiv2
Return Type: int
Method Name: countTuples
Arg Types: (string)
Problem Statement

Problem Statement

Consider the following function:
f(X) = Waai + X + Akari + X + Daisuki
Here, X is a string and + denotes string concatenation. Waai, Akari and Daisuki are constant non-empty strings.


You are given a String S. Compute and return the number of different tuples (Waai,Akari,Daisuki,X) such that f(X) equals S.

Notes

  • Two tuples (A,B,C,D) and (E,F,G,H) are considered equal if and only if A=E, B=F, C=G, and D=H.

Constraints

  • S will contain between 1 and 50 characters, inclusive.
  • Each character of S will be a lowercase letter ('a'-'z').
Examples
0)
"topcoderdivtwo"
Returns: 2

The possible tuples of (Waai, Akari, Daisuki, X) are the following ones: ("t", "pc", "derdivtwo", "o") ("topco", "er", "ivtwo", "d") ("topc", "derdivtw", "", "o") is not allowed since Daisuki is empty.

1)
"foxciel"
Returns: 0

The answer can be zero.

2)
"magicalgirl"
Returns: 4
3)
"waaiusushioakariusushiodaisuki"
Returns: 75
4)
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
Returns: 8924

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

Coding Area

Language: C++17 · define a public class AkariDaisukiDiv2 with a public method int countTuples(string S) · 87 test cases · 2 s / 256 MB per case

Submitting as anonymous