Alice and Bob are playing this game. Alice makes the first move. As always, she wants to win and this time she does a clever trick. She wants the starting position to be the K th lexicographically winning position for the first player i. Consider two positions A' 1 , B' 1 and A' 2 , B' 2. We consider the first position lexicographically smaller than the second if A1 is lexicographically smaller than A2, or if A1 is equal to A2 and B1 is lexicographically smaller than B2.
The first line of input consists of three integers, separated by a single space: N, M and K denoting the length of A , the length of B and K respectively. The second line consists of N small latin letters, corresponding to the string A. The third line consists of M small latin letters, corresponding to the string B.
Output A' on the first line of input and B' on the second line of input. Please, pay attention that some of these strings can be empty. If there's no such pair, output "no solution" without quotes. The given strings are and. So, the next two moves will consist of appending and to and respectively.
So, Bob will suffer lack of moves and hence Alice wins. Now, Bob will suffer lack of moves and hence Alice wins. So Alices looses. So, the list of start positions in lexicographical order where Alice wins are: ["", ""], ["", "c"], ["a", "c"], ["ab", ""], ["b", ""]. The one in this list is ["a", "c"]. Adds non-zero lengths. This takes care of the case. Sorts the lengths in. Scores of the 2 players.
For player 1. For player 2. In case of a tie. Print the result. This code is contributed by avanitrachhadiya Add one ;. Sort ;. Reverse ;. WriteLine gameMax S ;. Previous Minimize steps required to make all array elements same by adding 1, 2 or 5.
Next Determine the winner of a game of deleting Characters from a String. Recommended Articles. Find the winner of game of repeatedly removing the first character to empty given string. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments.
0コメント