Dialup
SRM 120 · 2002-11-13 · by honda89dude
Problem Statement
Each
Given a
Notes
- You must make at least 1 attempt per sequence (String).
Constraints
- attempts will contain between 1 and 50 elements, inclusive.
- Each element of attempts will have between 1 and 50 characters, inclusive.
- Each element of attempts will consist of only the characters 'S' and 'F', no other characters will be allowed.
{ "FFFS", "FFFF", "SFSFSSS" }
Returns: 9
In the first sequence, she will attempt to dial in 4 times. On the fourth attempt she succeeds, so no further attempts are needed. total = 4 In the second sequence, she attempts all 4 times, and does not get a successful connection. Total = 8 In the last sequence, she dials-in successfully on the first try. Total = 9.
{ "SSSSSFFFFFSSSSSFFFFFSFSFSSSSSSFFFFFSSSSSFFFFFSFSFS", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"}
Returns: 52
{ "F" }
Returns: 1
{ "S" }
Returns: 1
{ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFSF" , "SSF", "FFFFSSFSFSFSFSF", "SSFFSFSF"}
Returns: 56
{"FSFSFSF", "FFFFFFFF", "FSFSFSFSF", "SFSFSFSFSFSF" ,"FFFFFFFFFFFFFFFFFFFFS"}
Returns: 34
In the first sequence, she has two attempts until an S is found. total=2. In the second sequence, she has all failures, add 8 to the total. total=10. In the third sequence, she has two more attempts. total=12. In the fourth sequence, she dials-in successfully on the first try, so we stop searching. total=13. In the last sequence, she adds 21 more attempts. total = 34.
{"FFFFFSFSFFSFFSSFFFFSF"}
Returns: 6
She will continue to dial-in until the first 'S' is found, or until the last character is reached. The first occurrence of an 'S' is at position 6, so total=6.
Submissions are judged against all 20 archived test cases, of which 7 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Dialup with a public method int connect(vector<string> attempts) · 20 test cases · 2 s / 256 MB per case