Connection Status:
Competition Arena > Make737Easy
TCO19 SRM 737 · 2018-09-18 · by Blue.Mary · Brute Force
Class Name: Make737Easy
Return Type: int
Method Name: count
Arg Types: (string)
Problem Statement

Problem Statement

This problem has a non-standard time limit: 8 seconds.

You are given a String S. Each character of S is either '3' or '7'. Compute and return the number of 737-triples in this string.

An ordered triple (i,j,k) is called a 737-triple if and only if:

  • i, j, k are valid indices into S
  • i < j < k
  • S[i] = '7', S[j] = '3', and S[k] = '7'.

Constraints

  • S will contain between 1 and 373 characters, inclusive.
  • Each character of S will be either '3' or '7'.
Examples
0)
"737"
Returns: 1

The only 737-triple in this string corresponds to the zero-based indices (0,1,2).

1)
"777333"
Returns: 0

As we must have i < j < k, this string does not contain any 737-triples.

2)
"773377"
Returns: 8
3)
"73737"
Returns: 4
4)
"3"
Returns: 0

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

Coding Area

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

Submitting as anonymous