message
stringlengths
2
67k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
463
109k
cluster
float64
19
19
__index_level_0__
int64
926
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` r=[] white=0 black=0 for k in range(0,8): l=list(input()) r.append(l) for i in range(0,8): for j in range(0,8): if(r[i][j].isalpha()==True): if(r[i][j].islower()==True): if(r[i][j]=="q"): black=black+9 if(r[i][j]=="r"): black=black+5 if (r[i][j]=="b" or r[i][j] == "n" ) : black=black+3 if(r[i][j]=="p"): black=black+1 if(r[i][j].isupper()==True): r[i][j]=r[i][j].lower() if(r[i][j]=="q"): white=white+9 if(r[i][j]=="r"): white=white+5 if (r[i][j]=="b") or r[i][j] == "n" : white=white+3 if(r[i][j]=="p"): white=white+1 if(white>black): print("White") if(black>white): print("Black") if(black==white): print("Draw") ```
instruction
0
40,772
19
81,544
Yes
output
1
40,772
19
81,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` wh=0 bl=0 for i in range(8): a=list(input()) for j in range(8): if a[j]=='Q': wh+=9 elif a[j]=='R': wh+=5 elif a[j]=='B': wh+=3 elif a[j]=='N': wh+=3 elif a[j]=='P': wh+=1 elif a[j]=='q': bl+=9 elif a[j]=='r': bl+=5 elif a[j]=='b': bl+=3 elif a[j]=='n': bl+=3 elif a[j]=='p': bl+=1 if wh>bl: print('White') elif wh<bl: print('Black') else: print('Draw') ```
instruction
0
40,773
19
81,546
Yes
output
1
40,773
19
81,547
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` board = [input() for _ in range(8)] weight = {'q': 9, 'r': 5, 'b': 3, 'n': 3, 'p': 1} white, black = 0, 0 for i in board: for j in i: if j in weight: black += weight[j] elif j.lower() in weight: white += weight[j.lower()] if white > black: print('White') elif white < black: print('Black') else: print('Draw') ```
instruction
0
40,774
19
81,548
Yes
output
1
40,774
19
81,549
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` W,B=0,0 for i in range(8): n=list(input()) W=W+((n.count('Q'))*9 +(n.count('B')*3)+(n.count('R')*5)+(n.count('K')*3)+(n.count('P')*1)) B=B+((n.count('q'))*9 +(n.count('b')*3)+(n.count('r')*5)+(n.count('k')*3)+(n.count('p')*1)) if W>B: print("White") elif B>W: print("Black") else: print("Draw") ```
instruction
0
40,775
19
81,550
No
output
1
40,775
19
81,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` c,d=0,0 for i in range(8): a=input() for i in a: if(i=='q'): c+=9 elif(i=='r'): c+=5 elif(i=='b'): c+=3 elif(i=='k'): c+=3 elif(i=='p'): c+=1 elif(i=='Q'): d+=9 elif(i=='R'): d+=5 elif(i=='B'): d+=3 elif(i=='K'): d+=3 elif(i=='P'): d+=1 if(c>d): print("Black") elif(c<d): print("White") else: print("Draw") ```
instruction
0
40,776
19
81,552
No
output
1
40,776
19
81,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` dchess = {"q":9,"r":5,"b":3,"n":3,"p":1,"k":0} wsum = 0 bsum = 0 {} for i in range(8): t = input() for j in range(len(t)): if t[j] == ".": continue if t[j].isupper(): wsum = wsum + dchess[t[j].lower()] else: bsum = bsum + dchess[t[j]] if wsum > bsum: print("White") else: print("Black") ```
instruction
0
40,777
19
81,554
No
output
1
40,777
19
81,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger. For each chess piece we know its weight: * the queen's weight is 9, * the rook's weight is 5, * the bishop's weight is 3, * the knight's weight is 3, * the pawn's weight is 1, * the king's weight isn't considered in evaluating position. The player's weight equals to the sum of weights of all his pieces on the board. As A doesn't like counting, he asked you to help him determine which player has the larger position weight. Input The input contains eight lines, eight characters each β€” the board's description. The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters. The white pieces are denoted as follows: the queen is represented is 'Q', the rook β€” as 'R', the bishop β€” as'B', the knight β€” as 'N', the pawn β€” as 'P', the king β€” as 'K'. The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively. An empty square of the board is marked as '.' (a dot). It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on. Output Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal. Examples Input ...QK... ........ ........ ........ ........ ........ ........ ...rk... Output White Input rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR Output Draw Input rppppppr ...k.... ........ ........ ........ ........ K...Q... ........ Output Black Note In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5. In the second test sample the weights of the positions of the black and the white pieces are equal to 39. In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16. Submitted Solution: ``` weight1=0 weight2=0 for a in range(8): lst=input() for i in lst: if i=="Q": weight1+=9 elif i=="q": weight2+=9 elif i=="R": weight1+=5 elif i=="r": weight2+=5 elif i=="B": weight1+=3 elif i=="b": weight2+=3 elif i=="K": weight1+=3 elif i=="k": weight2+=3 elif i=="P": weight1+=1 elif i=="p": weight2+=1 if weight1>weight2: print("White") elif weight1<weight2: print("Black") else: print("Draw") ```
instruction
0
40,778
19
81,556
No
output
1
40,778
19
81,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Anton and Harris are playing a game to decide which of them is the king of problemsetting. There are three piles of stones, initially containing a, b, and c stones, where a, b, and c are distinct positive integers. On each turn of the game, the following sequence of events takes place: * The first player chooses a positive integer y and provides it to the second player. * The second player adds y stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns. The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if 1000 turns have passed without the second player losing. Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting! Input The first line of input contains three distinct positive integers a, b, and c (1 ≀ a, b, c ≀ 10^9) β€” the initial number of stones in piles 1, 2, and 3 respectively. Interaction The interaction begins by reading the integers a, b and c. After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently). On each turn, the first player (either you or the judge) must print a positive integer y (1 ≀ y ≀ 10^{12}). Then, the second player must print 1, 2, or 3, indicating which pile should have y stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn. If you are playing as Second and complete 1000 turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print 0 and will finish interaction. This means that your program is correct for this test case, and you should exit immediately. If you are playing as First and complete 1000 turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print -1 and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts. After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. In this problem, hacks are disabled. Example Input 5 2 6 3 0 Output First 2 3 Note In the sample input, the piles initially have 5, 2, and 6 stones. Harris decides to go first and provides the number 2 to Anton. Anton adds 2 stones to the third pile, which results in 5, 2, and 8. In the next turn, Harris chooses 3. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king. Submitted Solution: ``` import sys a, b, c = input().split(' ') a = int(a) b = int(b) c = int(c) l = [0, a, b, c] print('First') def interact(addend) : print(addend) sys.stdout.flush() ret = int(input()) return ret if interact(0) == 0 : # doing nothing leads to two equal exit() place = [0, 0, 0, 0] mx = [0, 0, 0, 0] if a > b and b > c : place[1] = 3 mx[3] = 1 place[2] = 2 mx[2] = 2 place[3] = 1 mx[1] = 3 elif a > c and c > b : place[1] = 3 mx[3] = 1 place[2] = 1 mx[1] = 2 place[3] = 2 mx[2] = 3 elif b > a and a > c : place[1] = 2 mx[2] = 1 place[2] = 3 mx[3] = 2 place[3] = 1 mx[1] = 3 elif b > c and c > a : place[1] = 1 mx[1] = 1 place[2] = 3 mx[3] = 2 place[3] = 2 mx[2] = 3 elif c > a and a > b : place[1] = 2 mx[2] = 1 place[2] = 1 mx[1] = 2 place[3] = 3 mx[3] = 3 elif c > b and b > a : place[1] = 1 mx[1] = 1 place[2] = 2 mx[2] = 2 place[3] = 3 mx[3] = 3 x = interact(l[mx[3]]*2 - l[mx[2]] - l[mx[1]]) l[x] += (l[mx[3]]*2 - l[mx[2]] - l[mx[1]]) if place[x] == 1 : l[interact(l[mx[3]] - l[mx[2]])] += l[mx[3]] - l[mx[2]] elif place[x] == 2 : l[interact(l[mx[3]] - l[mx[1]])] += l[mx[3]] - l[mx[1]] else : y = interact(l[mx[3]]*2 - l[mx[2]] - l[mx[1]]) l[y] += (l[mx[3]]*2 - l[mx[2]] - l[mx[1]]) if place[y] == 1 : l[interact(l[mx[3]] - l[mx[2]])] += l[mx[3]] - l[mx[2]] elif place[y] == 2 : l[interact(l[mx[3]] - l[mx[1]])] += l[mx[3]] - l[mx[1]] if(interact(0) == 0) : exit(0) else : print('what the fuck') ```
instruction
0
41,429
19
82,858
No
output
1
41,429
19
82,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Anton and Harris are playing a game to decide which of them is the king of problemsetting. There are three piles of stones, initially containing a, b, and c stones, where a, b, and c are distinct positive integers. On each turn of the game, the following sequence of events takes place: * The first player chooses a positive integer y and provides it to the second player. * The second player adds y stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns. The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if 1000 turns have passed without the second player losing. Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting! Input The first line of input contains three distinct positive integers a, b, and c (1 ≀ a, b, c ≀ 10^9) β€” the initial number of stones in piles 1, 2, and 3 respectively. Interaction The interaction begins by reading the integers a, b and c. After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently). On each turn, the first player (either you or the judge) must print a positive integer y (1 ≀ y ≀ 10^{12}). Then, the second player must print 1, 2, or 3, indicating which pile should have y stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn. If you are playing as Second and complete 1000 turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print 0 and will finish interaction. This means that your program is correct for this test case, and you should exit immediately. If you are playing as First and complete 1000 turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print -1 and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts. After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. In this problem, hacks are disabled. Example Input 5 2 6 3 0 Output First 2 3 Note In the sample input, the piles initially have 5, 2, and 6 stones. Harris decides to go first and provides the number 2 to Anton. Anton adds 2 stones to the third pile, which results in 5, 2, and 8. In the next turn, Harris chooses 3. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king. Submitted Solution: ``` x, y, z = map(int, input().split()) print("First") print(-179) ```
instruction
0
41,430
19
82,860
No
output
1
41,430
19
82,861
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Anton and Harris are playing a game to decide which of them is the king of problemsetting. There are three piles of stones, initially containing a, b, and c stones, where a, b, and c are distinct positive integers. On each turn of the game, the following sequence of events takes place: * The first player chooses a positive integer y and provides it to the second player. * The second player adds y stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns. The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if 1000 turns have passed without the second player losing. Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting! Input The first line of input contains three distinct positive integers a, b, and c (1 ≀ a, b, c ≀ 10^9) β€” the initial number of stones in piles 1, 2, and 3 respectively. Interaction The interaction begins by reading the integers a, b and c. After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently). On each turn, the first player (either you or the judge) must print a positive integer y (1 ≀ y ≀ 10^{12}). Then, the second player must print 1, 2, or 3, indicating which pile should have y stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn. If you are playing as Second and complete 1000 turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print 0 and will finish interaction. This means that your program is correct for this test case, and you should exit immediately. If you are playing as First and complete 1000 turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print -1 and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts. After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. In this problem, hacks are disabled. Example Input 5 2 6 3 0 Output First 2 3 Note In the sample input, the piles initially have 5, 2, and 6 stones. Harris decides to go first and provides the number 2 to Anton. Anton adds 2 stones to the third pile, which results in 5, 2, and 8. In the next turn, Harris chooses 3. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king. Submitted Solution: ``` a,b,c = input().split(' ') a,b,c = int(a),int(b),int(c) print('First') y = max(a,b,c) print(y) move = int(input()) if move == 1: a+=y elif move == 2: b+=y elif move == 3: c+=y y = int((max(a,b,c) - min(a,b,c))/2) print(y) if(int(input())==0): quit() ```
instruction
0
41,431
19
82,862
No
output
1
41,431
19
82,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem. Anton and Harris are playing a game to decide which of them is the king of problemsetting. There are three piles of stones, initially containing a, b, and c stones, where a, b, and c are distinct positive integers. On each turn of the game, the following sequence of events takes place: * The first player chooses a positive integer y and provides it to the second player. * The second player adds y stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns. The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if 1000 turns have passed without the second player losing. Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting! Input The first line of input contains three distinct positive integers a, b, and c (1 ≀ a, b, c ≀ 10^9) β€” the initial number of stones in piles 1, 2, and 3 respectively. Interaction The interaction begins by reading the integers a, b and c. After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently). On each turn, the first player (either you or the judge) must print a positive integer y (1 ≀ y ≀ 10^{12}). Then, the second player must print 1, 2, or 3, indicating which pile should have y stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn. If you are playing as Second and complete 1000 turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print 0 and will finish interaction. This means that your program is correct for this test case, and you should exit immediately. If you are playing as First and complete 1000 turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print -1 and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts. After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. In this problem, hacks are disabled. Example Input 5 2 6 3 0 Output First 2 3 Note In the sample input, the piles initially have 5, 2, and 6 stones. Harris decides to go first and provides the number 2 to Anton. Anton adds 2 stones to the third pile, which results in 5, 2, and 8. In the next turn, Harris chooses 3. Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king. Submitted Solution: ``` a = list(map(int, input().split())) print("First", flush=True) def get(y): print(y, flush=True) p = int(input()) if p <= 0: exit() return p-1 seq = [] for _ in range(3): p = get(1) seq.append(p) a[p] += 1 mx = max(a)+1 get(mx - a[seq[0]]) get(mx - a[seq[1]]) ```
instruction
0
41,432
19
82,864
No
output
1
41,432
19
82,865
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,562
19
83,124
Tags: implementation Correct Solution: ``` tests = int(input()) while tests > 0: field = input() # a * b = 12: (1, 12), (12, 1), (2, 6), (6, 2), (3, 4), (4, 3) <- 6 variants = [] for lines, columns in ((1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1)): def x_column(column): global field, columns, lines for line in range(lines): if field[column + columns * line] == 'O': return False return True for column in range(columns): if x_column(column): variants.append(str(lines) + 'x' + str(columns)) break print(len(variants), *variants) tests -= 1 ```
output
1
41,562
19
83,125
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,563
19
83,126
Tags: implementation Correct Solution: ``` n=int(input()) ar=[[1,12],[2,6],[3,4],[4,3],[6,2],[12,1]] for _ in range(n): s=str(input()) cou=0 ans="" skip=False for it in ar: a,b=it skip=False for j in range(b): if(skip): continue if(s[j]=="X"): if(a==1): ans+=f" {a}x{b}" cou+=1 skip=True for i in range(1,a): if(s[i*b + j]!="X"): break if(i==(a-1)): ans+=f" {a}x{b}" cou+=1 skip=True ans=f"{cou}"+ans print(ans) ```
output
1
41,563
19
83,127
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,564
19
83,128
Tags: implementation Correct Solution: ``` fact = [2,3,4,6] n = int(input()) l1 = [] for i in range(n): t = input() l2 = [] if t.count("X"): l2.append("1x12") for j in fact: for k in range(12//j): flag = 0 # print(j) for l in range(k,12,12//j): # print(k,j,l) if t[l] == "X": pass else: flag = 1 break if flag == 0: l2.append(str(j)+"x"+str(12//j)) break if t.count("X") == 12: l2.append("12x1") l1.append(l2) for i in l1: print(len(i),*i) ```
output
1
41,564
19
83,129
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,565
19
83,130
Tags: implementation Correct Solution: ``` import sys import math t = int(sys.stdin.readline()) for i in range(t): st = sys.stdin.readline() p1 = 1 p2 = [1] * 2 p3 = [1] * 3 p4 = [1] * 4 p6 = [1] * 6 p12 = 0 for j in range(1, 13): v = 0 if(st[j - 1] == 'X'): v = 1 p1 &= v p2[j % 2] &= v p3[j % 3] &= v p4[j % 4] &= v p6[j % 6] &= v p12 += v res = [] if(p12 > 0): res.append("1x12") if(sum(p6) > 0): res.append("2x6") if(sum(p4) > 0): res.append("3x4") if(sum(p3) > 0): res.append("4x3") if(sum(p2) > 0): res.append("6x2") if(p1 > 0): res.append("12x1") print(str(len(res)) + " " + " ".join(res)) ```
output
1
41,565
19
83,131
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,566
19
83,132
Tags: implementation Correct Solution: ``` def isMatch(n,s): x = 12//n res = [] for i in range(0,len(s),x): res.append(s[i:i+x]) for col in range(x): for row in range(len(res)): if res[row][col] != 'X': break elif res[row][col] == 'X' and row == len(res)-1 : return True return False def solve(s): res = [] if 'X' in s: res.append("1x12") for i in [2,3,4,6]: if isMatch(i,s): res.append(f'{i}x{12//i}') if s == 12*'X': res.append("12x1") print(len(res),sep=" ",end=" ") print(*res) def main() : # n,k = list(map(int, input().split(' '))) n = int(input()) # arr = input().split(' ') # s = input() # res='' arr = [] for _ in range(n): i = input() arr.append(i) for i in arr: solve(i) main() ```
output
1
41,566
19
83,133
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,567
19
83,134
Tags: implementation Correct Solution: ``` a=[1,2,3,4,6,12] for _ in range(int(input())): s=input() b=[] for i in a: m=12//i for j in range(m): if s[j::m]=="X"*i: b+=[(i,m)] break print(len(b), ' '.join(str(x)+"x"+str(y) for x,y in b)) ```
output
1
41,567
19
83,135
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,568
19
83,136
Tags: implementation Correct Solution: ``` def is_possible(request, a): b = 12 // a for i in range(b): if 'O' not in [request[i + j * b] for j in range(a)]: return True return False def solve(request): possible_ways = [1, 2, 3, 4, 6, 12] count_ways = 0 ways = [] for i in possible_ways: if is_possible(request, i): count_ways += 1 ways += ['%dx%d' % (i, 12 // i)] ways = [str(count_ways)] + ways return ' '.join(ways) def main(): n = int(input()) for _ in range(n): print(solve(input())) if __name__ == '__main__': main() ```
output
1
41,568
19
83,137
Provide tags and a correct Python 3 solution for this coding contest problem. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0
instruction
0
41,569
19
83,138
Tags: implementation Correct Solution: ``` t = int(input()) for _ in range(t): s = input().strip() S = [a == 'X' for a in s] ans = [] if s == 'O'*12: print(0) elif s == 'X'*12: print('6 1x12 2x6 3x4 4x3 6x2 12x1') else: ans.append('1x12') s1 = [S[6*i] for i in range(0,2)] s2 = [S[6*i+1] for i in range(0,2)] s3 = [S[6*i+2] for i in range(0,2)] s4 = [S[6*i+3] for i in range(0,2)] s5 = [S[6*i+4] for i in range(0,2)] s6 = [S[6*i+5] for i in range(0,2)] d2 = any([all(s1),all(s2),all(s3),all(s4),all(s5),all(s6)]) if d2: ans.append('2x6') s1 = [S[4*i] for i in range(0,3)] s2 = [S[4*i+1] for i in range(0,3)] s3 = [S[4*i+2] for i in range(0,3)] s4 = [S[4*i+3] for i in range(0,3)] d3 = any([all(s1),all(s2),all(s3),all(s4)]) if d3: ans.append('3x4') if d2: s1 = [S[3*i] for i in range(0,4)] s2 = [S[3*i+1] for i in range(0,4)] s3 = [S[3*i+2] for i in range(0,4)] d4 = any([all(s1),all(s2),all(s3)]) if d4: ans.append('4x3') if d3: s1 = [S[2*i] for i in range(0,6)] s2 = [S[2*i+1] for i in range(0,6)] d6 = any([all(s1),all(s2)]) if d6: ans.append('6x2') print('{} {}'.format(len(ans),' '.join(ans))) ```
output
1
41,569
19
83,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` t = int(input()) for i in range(0, t): str = input() answer = [] p = [1, 2, 3, 4, 6, 12] for j in range(0, len(p)): d1, d2 = p[j], 12 // p[j] cnt = [0 for h in range(0, d2)] for i2 in range(0, 12): tt = i2 % d2 cnt[tt] += (str[i2] == 'X') ans_cand = False for i2 in range(0, d2): if cnt[i2] == d1: ans_cand = True if ans_cand: answer.append('%dx%d' % (d1, d2)) print(len(answer), end = ' ') for j in range(0, len(answer)): print(answer[j], end = ' ') print() ```
instruction
0
41,570
19
83,140
Yes
output
1
41,570
19
83,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` ''' Created on 27.4.2016 @author: Ivan ''' import sys def main(): n = int(input()) list = [] for i in range(0, n): list.append(input()) for l in list: rez = [] for i in range(1, 13): if 12 % i == 0: a = i b = 12 // i parts = [l[k:k + b] for k in range(0, 12, b)] for k in range(0, b): flag = True for p in parts: if p[k] == 'O': flag = False break if flag: rez.append(str(a) + "x" + str(b)) break sys.stdout.write(str(len(rez)) + " ") for i in rez: sys.stdout.write(i + " ") print() if __name__ == '__main__': main() ```
instruction
0
41,571
19
83,142
Yes
output
1
41,571
19
83,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` n=int(input()) for i in range(n): a=input() ans=[] for j in [1,2,3,4,6,12]: if j==1 and "X" in a: ans.append("1x12") continue for k in range(12//j): f=0 for p in range(k,12,12//j): # print(j,k,p) if a[p]=="X": continue else: f=1 if f==0: ans.append("{}x{}".format(j,12//j)) break if len(ans)!=0: print(len(ans),end=" ") print(*ans) else: print(0) ```
instruction
0
41,572
19
83,144
Yes
output
1
41,572
19
83,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` # coding: utf-8 def check(a,b,s,ans): for j in range(b): if [s[k] for k in range(12) if k%b==j].count('X')==a: ans.append('%dx%d'%(a,b)) return ans return ans t = int(input()) for i in range(t): ans = [] s = input() ans = check(1,12,s,ans) ans = check(2,6,s,ans) ans = check(3,4,s,ans) ans = check(4,3,s,ans) ans = check(6,2,s,ans) ans = check(12,1,s,ans) if ans: print(len(ans),' '.join(ans)) else: print(0) ```
instruction
0
41,573
19
83,146
Yes
output
1
41,573
19
83,147
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` n=eval(input()) i=0 c=0 e=0 E='' while(i<n): b=input() y="n" print(b) while(c<12)and(y=="n"): if(b[c]=="X"): y="f" c+=1 if(y=="f"): E+= " 1x12 " e+=1 if(b[0]==b[6]=="X" or b[1]==b[7]=='X' or b[2]==b[8]=='X' or b[3]==b[9]=='X' or b[4]==b[10]=='X' or b[5]==b[11]=='X'): E+= " 2x6 " e+=1 if(b[0]==b[4]==b[8]=='X' or b[1]==b[5]==b[9]=='X' or b[2]==b[6]==b[10]=='X' or b[3]==b[7]==b[11]=='X' ): E+= " 3x4 " e+=1 if(b[0]==b[3]==b[6]==b[9]=='X' or b[1]==b[4]==b[7]==b[10]=='X' or b[2]==b[5]==b[8]==b[11]=='X' ): E+= " 4x3 " e+=1 if(b[0]==b[2]==b[4]==b[6]==b[8]==b[10]=='X' or b[1]==b[3]==b[5]==b[7]==b[9]==b[11]=='X' ): E+= " 6x2 " e+=1 if(b[0]==b[1] and b[0]==b[2] and b[0]==b[3] and b[0]==b[4] and b[0]==b[5] and b[0]==b[6] and b[0]==b[7] and b[0]==b[8]and b[0]==b[9] and b[0]==b[10] and b[0]==b[11] and b[0]=="X"): E+= " 12x1 " e+=1 print(e , E) E='' e=0 c=0 i+=1 ```
instruction
0
41,574
19
83,148
No
output
1
41,574
19
83,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` class MyApp(): def build(self,s): p = 0 res = [12,-1,-1,-1,-1,1] for i in range(12): if s[i] == 'O': res[0]-=1 res[5]-=1 if res[0] > 0:p+=1 if res[5] > 0:p+=1 X = 2 a = 0 REP=[6,4,3,2] ind = 0 for i in range(4): for _ in range(REP[ind]): if "".join(s[a::REP[ind]]) == 'X'*X: res[i+1] = 1 p+=1 break a+=1 X+=1 ind+=1 a=0 ans = ["1x12" ,"2x6" ,"3x4" ,"4x3" ,"6x2" ,"12x1"] print(p,end=" ") for i in range(6): if res[i] > 0:print(ans[i],end=" ") print() root = MyApp() for i in range(int(input())): root.build(input()) ```
instruction
0
41,575
19
83,150
No
output
1
41,575
19
83,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` for i in range(int(input())): s=input() c=0 for i in s: if i=='X': c+=1 if c==0: print(0) elif c==12: print("6 1x12 2x6 3x4 4x3 6x2 12x1") else: c,l=1,[1,0,0,0,0,0] if (s[0]=='X' and s[6]=='X' ) or (s[1]=='X' and s[7]=='X' ) or (s[2]=='X' and s[8]=='X' ) or (s[3]=='X' and s[9]=='X' ) or (s[4]=='X' and s[10]=='X' ) or (s[5]=='X' and s[11]=='X' ): l[1]=1 c+=1 if (s[0]=='X' and s[4]=='X' and s[8]=='X') or (s[1]=='X' and s[5]=='X' and s[9]=='X') or (s[2]=='X' and s[6]=='X' and s[10]=='X') or (s[3]=='X' and s[7]=='X' and s[11]=='X'): l[2]=1 c+=1 if (s[0]=='X' and s[3]=='X' and s[6]=='X' and s[9]=='X') or (s[1]=='X' and s[4]=='X' and s[7]=='X' and s[10]=='X') or (s[2]=='X' and s[5]=='X' and s[8]=='X' and s[11]=='X'): l[3]=1 c+=1 if (s[0]=='X' and s[2]=='X' and s[4]=='X' and s[6]=='X' and s[8]=='X' and s[10]=='X') or (s[1]=='X' and s[3]=='X' and s[5]=='X' and s[7]=='X' and s[9]=='X' and s[11]=='X'): l[4]=1 c+=1 print(c,"1*12",end=" ") if l[1]==1: print("2*6",end=" ") if l[2]==1: print("3*4",end=" ") if l[3]==1: print("4*3",end=" ") if l[4]==1: print("6*2",end=" ") print() ```
instruction
0
41,576
19
83,152
No
output
1
41,576
19
83,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses two positive integers a and b (aΒ·b = 12), after that he makes a table of size a Γ— b from the cards he put on the table as follows: the first b cards form the first row of the table, the second b cards form the second row of the table and so on, the last b cards form the last (number a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses. Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers a and b to choose. Help her win the game: print to her all the possible ways of numbers a, b that she can choose and win. Input The first line of the input contains integer t (1 ≀ t ≀ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the t tests on a separate line. The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The i-th character of the string shows the character that is written on the i-th card from the start. Output For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair a, b. Next, print on this line the pairs in the format axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by whitespaces. Examples Input 4 OXXXOXOOXOOX OXOXOXOXOXOX XXXXXXXXXXXX OOOOOOOOOOOO Output 3 1x12 2x6 4x3 4 1x12 2x6 3x4 6x2 6 1x12 2x6 3x4 4x3 6x2 12x1 0 Submitted Solution: ``` for _ in range(int(input())): s=list(input()) n=len(s) ans=[] d=[1,2,3,4,6,12] for item in d: z=item-1 for i in range(z,n,item): if s[i]!='X': break else: ans.append((12//item,item)) print(len(ans),end=' ') ans.sort() for item in ans: print(f'{item[0]}x{item[1]}',end=' ') print() ```
instruction
0
41,577
19
83,154
No
output
1
41,577
19
83,155
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,720
19
83,440
Tags: data structures, dp, greedy, sortings Correct Solution: ``` import os import sys from math import * from collections import * # from fractions import * # from heapq import* from bisect import * from io import BytesIO, IOBase def vsInput(): sys.stdin = open("input.txt", "r") sys.stdout = open("output.txt", "w") BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") ALPHA = "abcdefghijklmnopqrstuvwxyz/" M = 1000000007 EPS = 1e-6 def Ceil(a, b): return a // b + int(a % b > 0) def value(): return tuple(map(int, input().split())) def array(): return [int(i) for i in input().split()] def Int(): return int(input()) def Str(): return input() def arrayS(): return [i for i in input().split()] # -------------------------code---------------------------# n=int(input()) a=[int(x) for x in input()] b=[int(x) for x in input()] b.sort() save=list(b) done=set() ansmin=0 for x in range(n): done=False for y in range(len(b)): if b[y]>=a[x]: b.pop(y) done=True break if done==False: ansmin+=1 b.pop(0) b=list(save) ansmax=0 for x in range(n): done=False #print(b) for y in range(len(b)): if b[y]>a[x]: ansmax+=1 done=True b.pop(y) break if done==False: b.pop(0) print(ansmin) print(ansmax) ```
output
1
41,720
19
83,441
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,721
19
83,442
Tags: data structures, dp, greedy, sortings Correct Solution: ``` from collections import defaultdict n = int(input()) S =input() M = input() X = [] Sher = [] Moriarty = defaultdict(int) MorF = defaultdict(int) Mor = [] for i in S: Sher.append(int(i)) for j in M: Moriarty[int(j)]+=1 MorF[int(j)]+=1 Mor.append(int(j)) Sher.sort() Mor.sort() First = 0 Second = 0 for i in range(n): for j in range(Sher[i],10): if(MorF[j]>0): First+=1 MorF[j]-=1 break First = n-First for i in range(n): for j in range(Sher[i]+1,10): if(Moriarty[j]>0): Second+=1 Moriarty[j]-=1 break print(First) print(Second) ```
output
1
41,721
19
83,443
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,722
19
83,444
Tags: data structures, dp, greedy, sortings Correct Solution: ``` '''input 2 88 00 ''' n = int(input()) a, b = sorted(input()), sorted(input()) i, m = 0, 0 for x in b: if x >= a[i]: i += 1 m += 1 print(n - m) i, m = 0, 0 for y in b: if y > a[i]: i += 1 m += 1 print(m) ```
output
1
41,722
19
83,445
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,723
19
83,446
Tags: data structures, dp, greedy, sortings Correct Solution: ``` # https://codeforces.com/problemset/problem/777/B # Problem # Big O: # Time complexity: O(n log (n)) + 2*(O(n) + O(n))*O(k) = O(n)*O(k) # Space complexity: 3*O(n) = O(n) # Problem def value_index_greater_or_equal_than(ordered_list, number): for i in range(0, len(ordered_list)): element = ordered_list[i] if element >= number: return i return -1 def flicks(sherlocks_card, sorted_moriarty_card, prefer_greater_digit): moriartys_flicks = 0 sherlocks_flicks = 0 for sherlocks_digit in sherlocks_card: increment = 1 if prefer_greater_digit else 0 index = value_index_greater_or_equal_than( sorted_moriarty_card, sherlocks_digit + increment) index = index if index >= 0 else 0 moriartys_digit = sorted_moriarty_card[index] if (moriartys_digit > sherlocks_digit): sherlocks_flicks += 1 elif (moriartys_digit < sherlocks_digit): moriartys_flicks += 1 sorted_moriarty_card.pop(index) return moriartys_flicks, sherlocks_flicks def minimum_moriartys_flicks(sherlocks_card, sorted_moriarty_card): moriartys_flicks, _ = flicks(sherlocks_card, sorted_moriarty_card, False) return moriartys_flicks def maximum_sherlocks_flicks(sherlocks_card, sorted_moriarty_card): _, sherlocks_flicks = flicks(sherlocks_card, sorted_moriarty_card, True) return sherlocks_flicks # def minimum_moriartys_flicks(sherlocks_card, sorted_moriarty_card): # moriartys_flicks = 0 # for digit in sherlocks_card: # # guarantees minimum possible number of flicks Moriarty will get # index = value_index_greater_or_equal_than( # sorted_moriarty_card, digit) # if (index >= 0): # sorted_moriarty_card.pop(index) # else: # moriartys_flicks += 1 # sorted_moriarty_card.pop(0) # return moriartys_flicks # def maximum_sherlocks_flicks(sherlocks_card, sorted_moriarty_card): # sherlocks_flicks = 0 # for digit in sherlocks_card: # # guarantees maximum possible number of flicks that Sherlock can get from Moriarty # index = value_index_greater_or_equal_than( # sorted_moriarty_card, digit + 1) # if (index >= 0): # sherlocks_flicks += 1 # sorted_moriarty_card.pop(index) # else: # sorted_moriarty_card.pop(0) # return sherlocks_flicks def solve(number_of_digits, sherlocks_card, moriartys_card): moriartys_card.sort() min_moriartys_flicks = minimum_moriartys_flicks( sherlocks_card, moriartys_card.copy()) max_sherlocks_flicks = maximum_sherlocks_flicks( sherlocks_card, moriartys_card.copy()) return min_moriartys_flicks, max_sherlocks_flicks # Read input number_of_digits = int(input()) sherlocks_card = [int(x) for x in input()] moriartys_card = [int(x) for x in input()] moriartys_flicks, sherlocks_flicks = solve( number_of_digits, sherlocks_card, moriartys_card) print(moriartys_flicks) print(sherlocks_flicks) ```
output
1
41,723
19
83,447
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,724
19
83,448
Tags: data structures, dp, greedy, sortings Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- # # @Filename : 401_DIV2_B # @Date : 2017-09-18 16:34 # @Author : LunaFire # @Mail : 315135833@qq.com if __name__ == "__main__": n = int(input()) a, b = list(input()), list(input()) a.sort() b.sort() ia, ib, ret_1 = 0, 0, 0 while ib < n: if b[ib] >= a[ia]: ia += 1 ib += 1 else: ib += 1 ret_1 += 1 print(ret_1) ia, ib, ret_2 = 0, 0, 0 while ib < n: if b[ib] > a[ia]: ia += 1 ib += 1 ret_2 += 1 else: ib += 1 print(ret_2) ```
output
1
41,724
19
83,449
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,725
19
83,450
Tags: data structures, dp, greedy, sortings Correct Solution: ``` n=int(input()) s1=input() s2=input() st1=[] st2=[] for i in range(n): st1.append(int(s1[i])) st2.append(int(s2[i])) st2.sort() st1.sort() ded1=[] ded2=[] d1=0 d2=0 for i in range(n): for j in range(n): if st1[j]>st2[j]: d1+=1 elif st1[j]<st2[j]: d2+=1 ded1.append(d1) ded2.append(d2) st2.insert(0,st2[-1]) st2.pop() d1=0 d2=0 print(min(ded1)) print(max(ded2)) ```
output
1
41,725
19
83,451
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,726
19
83,452
Tags: data structures, dp, greedy, sortings Correct Solution: ``` n = int(input()) a = sorted(list(input())) b = sorted(list(input()), reverse = True) cnt1 = [0] * 10 cnt2 = [0] * 10 for i in range(n): cnt1[ord(b[i])-48]+=1 cnt2[ord(a[i])-48]+=1 A = 0 B = n for i in range(n): k = ord(a[i])-48 for j in range(k + 1, 10): if cnt1[j] > 0: A+=1 cnt1[j]-=1 break for i in range(n): k = ord(b[i])-48 for j in range(k, -1, -1): if cnt2[j] > 0: B-=1 cnt2[j]-=1 break print(B) print(A) ```
output
1
41,726
19
83,453
Provide tags and a correct Python 3 solution for this coding contest problem. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks.
instruction
0
41,727
19
83,454
Tags: data structures, dp, greedy, sortings Correct Solution: ``` from collections import defaultdict n = int(input()) s1 = input() s2 = input() occ = defaultdict(int) for i in s2: occ[int(i)]+=1 def find_min(x): global occ for i in range(x, 10): if occ[i] > 0: occ[i]-=1 return i for i in range(0, x): if occ[i] > 0: occ[i]-=1 return i mn = 0 for i in s1: y = find_min(int(i)) if y < int(i): mn+=1 print(mn) for i in s2: occ[int(i)]+=1 def find_closest(x): global occ for i in range(x+1, 10): if occ[i] > 0: occ[i] -=1 return i for i in range(0,x+1): if occ[i] > 0: occ[i]-=1 return i mx =0 for i in s1: y = find_closest(int(i)) if y > int(i): mx +=1 print(mx) ```
output
1
41,727
19
83,455
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` from collections import Counter n = int(input()) num1 = input() num2 = input() Sher = list(sorted(num1, reverse=True)) Mor = Counter(map(int, num2)) ans1 = 0 for i in range(n): temp = {k for k in Mor.keys() if k >= int(Sher[i])} if len(temp) == 0: ans1 += 1 else: Mor[min(temp)] -= 1 if Mor[min(temp)] == 0: del Mor[min(temp)] Mor = Counter(map(int, num2)) ans2 = 0 for i in range(n): temp = {k for k in Mor.keys() if k > int(Sher[i])} if len(temp) != 0: ans2 += 1 Mor[min(temp)] -= 1 if Mor[min(temp)] == 0: del Mor[min(temp)] print(ans1, ans2, sep='\n') ```
instruction
0
41,728
19
83,456
Yes
output
1
41,728
19
83,457
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` n=int(input()) s=str(input()) m=str(input()) marr=[0 for i in range(10)] marr2=[0 for i in range(10)] for i in m: marr[int(i)]+=1 marr2[int(i)]+=1 low=0 high=0 #print(marr,marr2) for i in s: i=int(i) b=0 for j in range(i,10): if marr[j]>0: marr[j]-=1 b=1 break if b==0: low+=1 #print(marr,marr2) for i in s: i=int(i) for j in range(i+1,10): #print(j,marr2[j]) if marr2[j]>0: marr2[j]-=1 high+=1 break print(low) print(high) ```
instruction
0
41,729
19
83,458
Yes
output
1
41,729
19
83,459
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` import bisect n = int(input()) sherlock = input() mori = sorted([int(i) for i in input()]) mori2 = mori.copy() sherlock_hits = 0 mori_hits = 0 for i in sherlock: el = int(i) idx = bisect.bisect(mori, el) if mori[idx - 1] == el: mori.remove(mori[idx - 1]) continue elif idx != len(mori): mori.remove(mori[idx]) else: mori_hits += 1 mori.remove(mori[0]) print(mori_hits) for i in sherlock: el = int(i) idx = bisect.bisect(mori2, el) if idx != len(mori2): mori2.remove(mori2[idx]) sherlock_hits += 1 else: mori2.remove(mori2[0]) print(sherlock_hits) ```
instruction
0
41,730
19
83,460
Yes
output
1
41,730
19
83,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` n=int(input()) s=sorted(list(map(int,input()))) m=sorted(list(map(int,input()))) j=0 min=n for i in m: if i>=s[j]: j,min=j+1,min-1 j=0 max=0 for i in m: if i>s[j]: max,j=max+1,j+1 print(min) print(max) ```
instruction
0
41,731
19
83,462
Yes
output
1
41,731
19
83,463
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` n=int(input()) a=sorted(map(int,input())) b=sorted(map(int,input())) morlick = sherlick=0 for i in range(n): morlick += 1 if b[i]<a[morlick] else 0 sherlick += 1 if b[i]>a[sherlick] else 0 print(morlick) print(sherlick) ```
instruction
0
41,732
19
83,464
No
output
1
41,732
19
83,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` n = int(input()) s1 = list(input()) s2 = list(input()) s1.sort() s2.sort() cnt = 0 for i in range(n): if s1[i] > s2[i]: cnt += 1 print(cnt) cnt = 0 used = [False] * n ind = 0 for i in range(n): for j in range(ind, n): if not used[j] and s1[i] < s2[j]: used[j] = True ind = j + 1 cnt += 1 break print(cnt) ```
instruction
0
41,733
19
83,466
No
output
1
41,733
19
83,467
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` from collections import Counter n=int(input()) a0=list(map(int,input())) b0=list(map(int,input())) a=Counter(a0) b=Counter(b0) c=0 d=0 for i in range(9): for i0 in range(i+1,10): if i in a and i0 in b: c=c+min(a[i],b[i0]) a[i]=a[i]-min(a[i],b[i0]) b[i]=b[i]-min(a[i],b[i0]) a=Counter(a0) b=Counter(b0) for i in range(10): for i0 in range(i,10): if i in a and i0 in b: d=d+min(a[i],b[i0]) a[i]=a[i]-min(a[i],b[i0]) b[i]=b[i]-min(a[i],b[i0]) print(n-d) print(c) ```
instruction
0
41,734
19
83,468
No
output
1
41,734
19
83,469
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and decided to continue their competitions in peaceful game of Credit Cards. Rules of this game are simple: each player bring his favourite n-digit credit card. Then both players name the digits written on their cards one by one. If two digits are not equal, then the player, whose digit is smaller gets a flick (knock in the forehead usually made with a forefinger) from the other player. For example, if n = 3, Sherlock's card is 123 and Moriarty's card has number 321, first Sherlock names 1 and Moriarty names 3 so Sherlock gets a flick. Then they both digit 2 so no one gets a flick. Finally, Sherlock names 3, while Moriarty names 1 and gets a flick. Of course, Sherlock will play honestly naming digits one by one in the order they are given, while Moriary, as a true villain, plans to cheat. He is going to name his digits in some other order (however, he is not going to change the overall number of occurences of each digit). For example, in case above Moriarty could name 1, 2, 3 and get no flicks at all, or he can name 2, 3 and 1 to give Sherlock two flicks. Your goal is to find out the minimum possible number of flicks Moriarty will get (no one likes flicks) and the maximum possible number of flicks Sherlock can get from Moriarty. Note, that these two goals are different and the optimal result may be obtained by using different strategies. Input The first line of the input contains a single integer n (1 ≀ n ≀ 1000) β€” the number of digits in the cards Sherlock and Moriarty are going to use. The second line contains n digits β€” Sherlock's credit card number. The third line contains n digits β€” Moriarty's credit card number. Output First print the minimum possible number of flicks Moriarty will get. Then print the maximum possible number of flicks that Sherlock can get from Moriarty. Examples Input 3 123 321 Output 0 2 Input 2 88 00 Output 2 0 Note First sample is elaborated in the problem statement. In the second sample, there is no way Moriarty can avoid getting two flicks. Submitted Solution: ``` import sys n = int(input()) s = input() s1 = input() a = [] b = [] for i in s: a.append(int(i)) for j in s1: b.append(int(j)) a.sort() b.sort() b1 = b[:] b.reverse() ans2 = 0 ans1 = 0 lst = 0 for i in range(n): if (a[i] > b1[-1]): ans1 += 1 b.reverse() lst = -1 for i in range(n): for j in range(lst + 1, n): lst = j if a[i] < b[j]: b[j] = 0 ans2 += 1 break print(ans1) print(ans2) ```
instruction
0
41,735
19
83,470
No
output
1
41,735
19
83,471
Provide a correct Python 3 solution for this coding contest problem. There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers. The conditions for completing the puzzle are * You must have one combination of the same numbers. * The remaining 12 numbers are 4 combinations of 3 numbers. The combination of three numbers is either three of the same numbers or three consecutive numbers. However, sequences such as 9 1 2 are not considered consecutive numbers. * The same number can be used up to 4 times. Create a program that reads a string of 13 numbers and outputs all the numbers that can complete the puzzle in ascending order. If you cannot complete the puzzle by adding any number from 1 to 9, output 0. For example, if the given string is 3456666777999 If there is a "2", 234 567 666 77 999 If there is a "3", then 33 456 666 777 999 If there is a "5", then 345 567 666 77 999 If there is an "8", then 345 666 678 77 999 And so on, the puzzle is complete when one of the numbers 2 3 5 8 is added. Note that "6" is fine, but it will be used for the 5th time, so it cannot be used in this example. Input The input consists of multiple datasets. For each dataset, 13 numbers are given on one line. The number of datasets does not exceed 50. Output For each dataset, the numbers that can complete the puzzle are output on one line in ascending order, separated by blanks. Example Input 3649596966777 6358665788577 9118992346175 9643871425498 7755542764533 1133557799246 Output 2 3 5 8 3 4 1 2 3 4 5 6 7 8 9 7 8 9 1 2 3 4 6 7 8 0
instruction
0
41,965
19
83,930
"Correct Solution: ``` from collections import deque try: while True: a = list(sorted(map(int, input()))) result = [] for i in range(1, 10): if a.count(i) == 4: continue _a = sorted(a+[i]) dq = deque([(_a, 0)]) while dq: hand, mentu = dq.popleft() if mentu == 5: if not hand: result.append(i) break continue elif mentu > 5: continue current = hand[0] if hand.count(current) >= 2: dq.append((hand[2:], mentu+1)) if hand.count(current) >= 3: dq.append((hand[3:], mentu+1)) if current+1 in hand and current+2 in hand: _hand = hand[:] del _hand[0] del _hand[_hand.index(current+1)] del _hand[_hand.index(current+2)] dq.append((_hand, mentu+1)) print(" ".join(map(str, result)) if result else 0) except EOFError: exit() ```
output
1
41,965
19
83,931
Provide a correct Python 3 solution for this coding contest problem. There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers. The conditions for completing the puzzle are * You must have one combination of the same numbers. * The remaining 12 numbers are 4 combinations of 3 numbers. The combination of three numbers is either three of the same numbers or three consecutive numbers. However, sequences such as 9 1 2 are not considered consecutive numbers. * The same number can be used up to 4 times. Create a program that reads a string of 13 numbers and outputs all the numbers that can complete the puzzle in ascending order. If you cannot complete the puzzle by adding any number from 1 to 9, output 0. For example, if the given string is 3456666777999 If there is a "2", 234 567 666 77 999 If there is a "3", then 33 456 666 777 999 If there is a "5", then 345 567 666 77 999 If there is an "8", then 345 666 678 77 999 And so on, the puzzle is complete when one of the numbers 2 3 5 8 is added. Note that "6" is fine, but it will be used for the 5th time, so it cannot be used in this example. Input The input consists of multiple datasets. For each dataset, 13 numbers are given on one line. The number of datasets does not exceed 50. Output For each dataset, the numbers that can complete the puzzle are output on one line in ascending order, separated by blanks. Example Input 3649596966777 6358665788577 9118992346175 9643871425498 7755542764533 1133557799246 Output 2 3 5 8 3 4 1 2 3 4 5 6 7 8 9 7 8 9 1 2 3 4 6 7 8 0
instruction
0
41,968
19
83,936
"Correct Solution: ``` def check_set(hand): set_list = [] for i in range(9): if hand.count(i + 1) >= 3: set_list.append([i + 1, i + 1, i + 1]) if i + 1 in hand and i + 2 in hand and i + 3 in hand: set_list.append([i + 1, i + 2, i + 3]) return set_list def check_winning(hand): if len(hand) == 2: if hand[0] == hand[1]: return True else: return False set_tmp_list = check_set(hand) if len(set_tmp_list) == 0: return False for set_tmp in set_tmp_list: hand_tmp = hand[:] for i in range(3): hand_tmp.remove(set_tmp[i]) res = check_winning(hand_tmp) if res: break else: continue return res while True: try: inp = list(map(int, list(input()))) ans = [] for i in range(9): if inp.count(i + 1) >= 4: continue inp_tmp = inp[:] inp_tmp.append(i + 1) if check_winning(inp_tmp): ans.append(i + 1) if len(ans) == 0: print(0) else: print(*ans) except: break ```
output
1
41,968
19
83,937
Provide tags and a correct Python 3 solution for this coding contest problem. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins? Input The single line contains two integers a and b (1 ≀ a, b ≀ 6) β€” the numbers written on the paper by the first and second player, correspondingly. Output Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. Examples Input 2 5 Output 3 0 3 Input 2 4 Output 2 1 3 Note The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct. You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
instruction
0
42,423
19
84,846
Tags: brute force Correct Solution: ``` a,b=map(int,input().split()) x=int(1) aa=bb=d=int(0) while x<=6: if abs(a-x)<abs(b-x): aa=aa+1 elif abs(a-x)>abs(b-x): bb=bb+1 else: d=d+1 x=x+1 print(aa,d,bb) ```
output
1
42,423
19
84,847
Provide tags and a correct Python 3 solution for this coding contest problem. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins? Input The single line contains two integers a and b (1 ≀ a, b ≀ 6) β€” the numbers written on the paper by the first and second player, correspondingly. Output Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. Examples Input 2 5 Output 3 0 3 Input 2 4 Output 2 1 3 Note The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct. You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
instruction
0
42,424
19
84,848
Tags: brute force Correct Solution: ``` """ β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ•β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β• """ a, b = map(int, input().split()) m, n , o = 0, 0 ,0 for i in range(1, 7): if abs(a - i) < abs(b - i): m += 1 elif abs(a - i) == abs(b - i): n += 1 else: o += 1 print(m, n, o) ```
output
1
42,424
19
84,849
Provide tags and a correct Python 3 solution for this coding contest problem. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins? Input The single line contains two integers a and b (1 ≀ a, b ≀ 6) β€” the numbers written on the paper by the first and second player, correspondingly. Output Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. Examples Input 2 5 Output 3 0 3 Input 2 4 Output 2 1 3 Note The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct. You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
instruction
0
42,425
19
84,850
Tags: brute force Correct Solution: ``` a,b=map(int,input().split()) c=0 d=0 e=0 for i in range(1,7): if(abs(a-i)<abs(b-i)): c=c+1 elif(abs(a-i)>abs(b-i)): d=d+1 elif(abs(a-i)==abs(b-i)): e=e+1 print(c,e,d,sep=" ") ```
output
1
42,425
19
84,851
Provide tags and a correct Python 3 solution for this coding contest problem. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins? Input The single line contains two integers a and b (1 ≀ a, b ≀ 6) β€” the numbers written on the paper by the first and second player, correspondingly. Output Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. Examples Input 2 5 Output 3 0 3 Input 2 4 Output 2 1 3 Note The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct. You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
instruction
0
42,426
19
84,852
Tags: brute force Correct Solution: ``` first=0 second=0 draw=0 z,x=list(map(int,input().split())) for i in range(1,7): #print('(i-z)=%d (i-x)=%d'%(abs(i-z),abs(i-x))) if abs(i-z)<abs(i-x): first+=1 # print('first',first) elif abs(i-z)>abs(i-x) : second+=1 # print('second',second) else: draw+=1 # print('draw',draw) print(first,draw,second) ```
output
1
42,426
19
84,853
Provide tags and a correct Python 3 solution for this coding contest problem. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins? Input The single line contains two integers a and b (1 ≀ a, b ≀ 6) β€” the numbers written on the paper by the first and second player, correspondingly. Output Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly. Examples Input 2 5 Output 3 0 3 Input 2 4 Output 2 1 3 Note The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct. You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
instruction
0
42,427
19
84,854
Tags: brute force Correct Solution: ``` a, b = (int(s) for s in input().split()) results = [0, 0, 0] for i in range(1, 7): if abs(a - i) < abs(b - i): results[0] += 1 elif abs(a - i) > abs(b - i): results[2] += 1 else: results[1] += 1 print(results[0], results[1], results[2]) ```
output
1
42,427
19
84,855