subject

An ordinary deck of playing cards contains 52 cards, each of which has a suit and a value. Most card games require that a deck be shuffled at the beginning of a play. However, sometimes the deck isn't shuffled well enough, and there are arrangements of cards in the deck which may cause a bias in the play. Two such arrangements are a same-suit sequence and an ascending sequence. Asame-suit sequence is simply a sequence of consecutive cards in the deck with the same suit. Anascending sequence is a sequence of consecutive cards in the deck that follow one another in increasing value, with Ace following King and preceding two. Thus, 2S, 5S, KS, 3S AS is a same-suit sequence of length five, and 9C, 10D, JC, QS, KH, AC, 2D is anascending sequence of length seven, and 2H 3H 4H 5H 6H is both a same-suit and ascending sequence of length five. The Problem
Given a deck of cards, determine the length of the longest same-suit sequence and the length of the longest ascending sequence.
The Input (to be read from standard input)
The first line will contain a single positive integer, c (CS25), representing the number of test cases to process. The test cases follow.
Each test case will be two lines long, each line will contain a string of 52 characters. The first line represents the first 26 cards in the deck and the second line represents the next 26 cards, in order in the deck
Each card will be represented with two characters, one for its kind and one for its suit, in that order. The 13 characters representing kinds are '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', in ascending order. The 4 characters representing suits are 'C', 'D', 'H' and 'S'.
The Output (to be printed to standard out)
For each input case, output two space separated integers on a line by themselves: the length of the longest same-suit sequence and the length of the longest ascending sequence, respectively.
Sample Input
2
255SKS3SAS9CTDJCOSKHAC2D2H3H4H5H6HQ D9SJDSHAH4D7CJS 8C KD5C2CQHTS9H5DJHQC4C8D7STHAD 7H6D6C6S9D4S7DKC3D8S3CTC QCTD4C8D7STHADZH2D3S6D6C6S9D4 SAS 7D2HKC5H3DTC8S9C3H3C QD9SQSJDSHAH2SKS4D4H557CJS8CKD5C2CA CQHJCTSCHKH9H5DJH
Sample Output
5 7
3 2
Implementation Restrictions/Run-Time/Memory Restrictions
1. You must read the deck for each case into statically allocated string(s).
2. For full credit, your algorithm must run in O(n) time. This means that you can only do a few separate single loops through a deck of cards for full credit. In particular a correct solution that has a pair of nested loops will NOT receive full credit.
3. For full credit, you must have appropriately designed functions. In particular, any correct solution which is fully coded in main will NOT receive full credit.
You must only declare your string variables INSIDE your case loop.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 23.06.2019 01:50
Free points just awnser this. what should i watch on netflix
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
You know the right answer?
An ordinary deck of playing cards contains 52 cards, each of which has a suit and a value. Most card...
Questions
question
Mathematics, 23.08.2019 20:30
question
Geography, 23.08.2019 20:30
question
Mathematics, 23.08.2019 20:30
Questions on the website: 13722363