GogoXMarisaKirisima
SRM 530 · 2011-11-22 · by dolphinigle
Problem Statement
Like all other software engineers, Gogo likes to "read" virtual novels. In particular, he's currently "reading" a novel titled Touhou, with Marisa Kirisima as its main protagonist. There are N stages in Touhou, numbered 0 through N-1. A playthrough of the novel always starts at the stage 0. The playthrough then may visit some other stages, based on the player's choices (a stage may be visited multiple times). A playthrough is successful if it terminates at the stage N-1.
In each stage, Gogo can either finish the playthrough or choose one of the available options that advance Marisa to other stages. You are given a
Gogo wants to make as many successful playthroughs as possible, one after another. However, there is an additional constraint: Each playthrough must contain at least one choice Gogo never made in any of the previous playthroughs.
Return the maximum number of successful playthroughs that Gogo can play. If there are no such playthrough, return 0.
Constraints
- choices will contain between 2 and 50 elements, inclusive.
- Each element of choices will contain N characters, where N is the number of elements in choices.
- Each character in choices will be either 'Y', or 'N'.
- For each i, choices[i][i] will be 'N'.
{"NYN"
,"YNY"
,"NNN"}
Returns: 2
For example, he can perform the following two playthroughs (in the given order): 0 -> 1 -> 2 0 -> 1 -> 0 -> 1 -> 2 In the first playthrough, both choices (0->1 and 1->2) have never been made before. In the second playthrough, the choice 1->0 has never been made before. Note that the order of playing the playthroughs is important. Should Gogo start by performing the second playthrough, the first playthrough would then be invalid, as it would not contain any new choices.
{"NNY"
,"YNY"
,"YNN"}
Returns: 2
{"NN"
,"NN"}
Returns: 0
{"NYYY"
,"NNNY"
,"NNNY"
,"NNNN"}
Returns: 3
{"NYYYY"
,"YNYYY"
,"YYNYY"
,"YYYNY"
,"YYYYN"}
Returns: 17
Submissions are judged against all 197 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class GogoXMarisaKirisima with a public method int solve(vector<string> choices) · 197 test cases · 2 s / 256 MB per case