message
stringlengths
2
44.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
276
109k
cluster
float64
23
23
__index_level_0__
int64
552
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms that are cut out. Create a program that reads "Data to be input to the machine" and outputs the number of rectangles and diamonds manufactured. <image> Input The input is given in the following format: a1, b1, c1 a2, b2, c2 :: The data to be entered into the machine is given in multiple lines. On line i, the integers ai, bi, which represent the lengths of two adjacent sides of the i-th parallelogram, and the integer ci, which represents the length of the diagonal, are given, separated by commas (1 ≤ ai, bi, ci ≤ 1000). , ai + bi> ci). The number of data does not exceed 100. Output The first line outputs the number of rectangles manufactured, and the second line outputs the number of diamonds manufactured. Example Input 3,4,5 5,5,8 4,4,4 5,4,3 Output 1 2 Submitted Solution: ``` hisi=0 tyou=0 while True: try: a,b,c=map(int,input().split(",")) if a**2+b**2==c**2: tyou +=1 elif a==b: hisi +=1 except: print(tyou) print(hisi) ```
instruction
0
73,209
23
146,418
No
output
1
73,209
23
146,419
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms that are cut out. Create a program that reads "Data to be input to the machine" and outputs the number of rectangles and diamonds manufactured. <image> Input The input is given in the following format: a1, b1, c1 a2, b2, c2 :: The data to be entered into the machine is given in multiple lines. On line i, the integers ai, bi, which represent the lengths of two adjacent sides of the i-th parallelogram, and the integer ci, which represents the length of the diagonal, are given, separated by commas (1 ≤ ai, bi, ci ≤ 1000). , ai + bi> ci). The number of data does not exceed 100. Output The first line outputs the number of rectangles manufactured, and the second line outputs the number of diamonds manufactured. Example Input 3,4,5 5,5,8 4,4,4 5,4,3 Output 1 2 Submitted Solution: ``` import sys j = [int(a)**2 + int(b)**2 - int(c)**2 for line in sys.stdin for a,b,c in line.split(",")] print(len([i for i in j if not i])) print(len([i for i in j if i])) ```
instruction
0
73,210
23
146,420
No
output
1
73,210
23
146,421
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no
instruction
0
73,219
23
146,438
"Correct Solution: ``` lst = [set(map(int, input().split())) for _ in range(6)] rec = [] while lst: x = lst[0] count = lst.count(x) if count % 2 == 1: print("no") break rec.append((count, x)) for _ in range(count): lst.pop(lst.index(x)) else: if len(rec) == 1: if len(rec[0][1]) == 1: print("yes") else: print("no") elif len(rec) == 2: rec.sort() if rec[0][1] & rec[1][1] == rec[0][1]: print("yes") else: print("no") elif len(rec) == 3: if len(rec[0][1]) == len(rec[1][1]) == len(rec[2][1]) == 2 and (rec[2][1] & (rec[0][1] | rec[1][1]) == rec[2][1]): print("yes") else: print("no") ```
output
1
73,219
23
146,439
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no
instruction
0
73,220
23
146,440
"Correct Solution: ``` a = [] for _ in range(6):a.append(sorted(list(map(int, input().split())))) a.sort(key = lambda x:x[1]) a.sort(key = lambda x:x[0]) print("yes" if a[0] == a[1] and a[2] == a[3] and a[4] == a[5] and a[0][0] == a[2][0] and a[0][1] == a[4][0] and a[2][1] == a[4][1] else "no") ```
output
1
73,220
23
146,441
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no
instruction
0
73,221
23
146,442
"Correct Solution: ``` c=[[0,0]]*6 for i in range(6): a,b=sorted(map(int,input().split())) c[i]=[a,b] c.sort() for i in range(0,6,2): if c[i]!=c[i+1]:print('no');break else:print(['no','yes'][c[0][0]==c[2][0] and c[0][1]==c[4][0] and c[2][1]==c[4][1]]) ```
output
1
73,221
23
146,443
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no
instruction
0
73,222
23
146,444
"Correct Solution: ``` A = sorted(sorted(map(int, input().split())) for i in range(6)) if all(a==b for a, b in zip(A[::2], A[1::2])): p, q, r = A[::2] if (p[0] in q and p[1] in r and q[q.index(p[0])^1] == r[r.index(p[1])^1]) or (p[0] in r and p[1] in q and r[r.index(p[0])^1] == q[q.index(p[1])^1]): print("yes") else: print("no") else: print("no") ```
output
1
73,222
23
146,445
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no Submitted Solution: ``` a = [] for _ in range(6):a.append(sorted(list(map(int, input().split())))) a.sort(key = lambda x:x[1]) a.sort(key = lambda x:x[0]) print("yes" if a[0] == a[1] and a[2] == a[3] and a[4] == a[5] and a[0][0] == a[2][0] and a[0][1] == a[3][0] and a[2][1] == a[3][1] else "no") ```
instruction
0
73,223
23
146,446
No
output
1
73,223
23
146,447
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no Submitted Solution: ``` A = sorted(sorted(map(int, input().split())) for i in range(6)) if all(a==b for a, b in zip(A[::2], A[1::2])): p, q, r = A[::2] if (p[0] in q and p[1] in r and q[q.index(p[0])^1] == r[r.index(p[1])^1]) or (p[0] in r and p[1] in q and r[r.index(p[0])^1] == q[q.index(p[1])^1]): print("yes") else: print("no") ```
instruction
0
73,224
23
146,448
No
output
1
73,224
23
146,449
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no Submitted Solution: ``` lst = [set(map(int, input().split())) for _ in range(6)] rec = [] while lst: x = lst[0] count = lst.count(x) if count % 2 == 1: print("no") break rec.append((count, x)) for _ in range(count): lst.pop(lst.index(x)) else: if len(rec) == 1: if len(rec[0][1]) == 1: print("yes") else: print("no") elif len(rec) == 2: rec.sort() if rec[0][1] & rec[1][1] == rec[0][1]: print("yes") else: print("no") elif len(rec) == 3: if len(rec[0][1]) == len(rec[1][1]) == len(rec[2][1]) == 2 and (rec[2][1] in rec[0][1] | rec[1][1]): print("yes") else: print("no") ```
instruction
0
73,225
23
146,450
No
output
1
73,225
23
146,451
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or fold the drawing paper. Given six rectangles, write a program to determine if you can make a rectangular parallelepiped using them. Input The input is given in the following format. h1 w1 h2 w2 h3 w3 h4 w4 h5 w5 h6 w6 The input consists of 6 lines, each line given the integer hi (1 ≤ hi ≤ 1000) for the vertical length of each rectangle and the integer wi (1 ≤ wi ≤ 1000) for the horizontal length. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 2 2 2 3 2 3 2 3 2 2 3 2 Output yes Input 2 2 2 3 2 3 2 3 2 2 2 2 Output no Submitted Solution: ``` A = sorted(sorted(map(int, input().split())) for i in range(6)) if all(a==b for a, b in zip(A[::2], A[1::2])): print("yes") else: print("no") ```
instruction
0
73,226
23
146,452
No
output
1
73,226
23
146,453
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,239
23
146,478
"Correct Solution: ``` import sys for i in sys.stdin: a,l,x=map(int,i.split()) print((a*(4*l*l-a*a)**.5+2*l*((l+x)**2-l*l)**.5)/4) ```
output
1
73,239
23
146,479
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,240
23
146,480
"Correct Solution: ``` import sys for s in sys.stdin:a,l,x=map(float,s.split());print(a/2*(l*l-a*a/4)**.5+l/2*(2*l*x+x*x)**.5) ```
output
1
73,240
23
146,481
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,241
23
146,482
"Correct Solution: ``` import sys for s in sys.stdin: a,l,x=map(float,s.split()) print(a/2*(l*l-a*a/4)**.5+l/2*(2*l*x+x*x)**.5) ```
output
1
73,241
23
146,483
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,242
23
146,484
"Correct Solution: ``` from math import sqrt try: while 1: a, l, x = map(int, input().split()) print("%.10f" % (l*sqrt(x*(2*l+x))/2 + a*sqrt(4*l**2 - a**2)/4)) except EOFError: ... ```
output
1
73,242
23
146,485
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,243
23
146,486
"Correct Solution: ``` import math while True : try : a, l, x = map(int, input().split()) except EOFError : break HC = math.sqrt(l**2 - a**2 / 4) I = math.sqrt(((l+x)/2)**2 - l**2 / 4) S1 = a * HC / 2 S2 = l * I / 2 print('{:.8f}'.format(S1 + S2*2)) ```
output
1
73,243
23
146,487
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,244
23
146,488
"Correct Solution: ``` import math while True: try: a,l,x=map(int, input().split()) temp=(l+x)/2 except EOFError: break def heron(i,j,k): d = (i+j+k)/2 return math.sqrt(d*(d-i)*(d-j)*(d-k)) print((str(heron(a,l,l)+heron(l,temp,temp)*2))) ```
output
1
73,244
23
146,489
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,245
23
146,490
"Correct Solution: ``` while True: try: a, l, x = map(int, input().split()) except EOFError: break s1 = (l + l + x) / 2 v1 = (s1 * (l / 2) * (l / 2) * (x / 2)) ** (1 / 2) s2 = (l + l + a) / 2 v2 = (s2 * (s2 - l) * (s2 - l) * (s2 - a)) ** (1 / 2) print(v1 * 2 + v2) ```
output
1
73,245
23
146,491
Provide a correct Python 3 solution for this coding contest problem. Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these lengths are l), which have the same length, actually have an additional length x minutes. In order to increase the area of ​​the open part, let's make two new triangular ADCs and BECs by pulling the slack part. Points D and E exist outside the triangle ABC. These two new triangles are caused by slack, and the sum of the lengths of side BE and side EC and the sum of the lengths of side AD and side DC must be l + x. You determine the points D and E so that the sum M of the areas of these three triangles is maximized. As KND's neighbor, you decide to write a program to calculate the maximum area of ​​skin (M) to look out of your clothes, using a, l, x as inputs to find out how sexy his chest is. did. Constraints The input satisfies the following conditions. * All inputs are integers. * 1 ≤ a ≤ 1000 * 1 ≤ l ≤ 1000 * 1 ≤ x ≤ 1000 Input The input consists of multiple test cases. One test case is given in the following format. The end of input is indicated by EOF. a l x here, * a: Length of side AB of triangle ABC * l: Length of two sides AC and BC of triangle ABC * x: Slack on two sides AC, BC Is. Output Output the maximum area for each test case on one line. This value should not differ more than 10-5 from the value of the judge output. Example Input 2 2 1 2 3 1 3 2 3 2 3 5 Output 3.9681187851 6.7970540913 6.5668891783 13.9527248554
instruction
0
73,246
23
146,492
"Correct Solution: ``` import sys for line in sys.stdin: a,l,x=map(float,line.split()) center=1/2*a*(l**2-(a/2)**2)**0.5 side=1/2*l*(((l+x)/2)**2-(l/2)**2)**0.5 print("{0:.10f}".format(center+side*2)) ```
output
1
73,246
23
146,493
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,287
23
146,574
"Correct Solution: ``` while True: h,w = map(int, input().split()) if (h == 0 and w == 0): break for i in range(h): if (i % 2 == 0): print("#."*(w//2) + "#"*(w%2)) elif (i % 2 == 1): print(".#"*(w//2) + "."*(w%2)) print() ```
output
1
73,287
23
146,575
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,288
23
146,576
"Correct Solution: ``` while 1: h,w=map(int,input().split()) if h==0:break for i in range(h):print(('#.'*w)[i%2:][:w]) print() ```
output
1
73,288
23
146,577
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,289
23
146,578
"Correct Solution: ``` while True: h,w = map(int,input().split()) if h+w == 0: break; for i in range(h): for j in range(w): print("." if (i+j)&1 else "#",end='') print() print() ```
output
1
73,289
23
146,579
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,290
23
146,580
"Correct Solution: ``` kk=0 while kk==0: h,w=map(int,input().split()) if h==0 and w==0: break else: for i in range(h): if i%2==0: s="#" else: s="." for k in range(w-1): if s[-1]=="#": s=s+"." else: s=s+"#" print(s) print("") ```
output
1
73,290
23
146,581
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,291
23
146,582
"Correct Solution: ``` import sys while True: y,x = map(int,input().split()) if x==y==0: break for i in range(y): for j in range(x): if (i+j)%2==0: sys.stdout.write("#") else: sys.stdout.write(".") print() print() ```
output
1
73,291
23
146,583
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,292
23
146,584
"Correct Solution: ``` while True: h,w=map(int,input().split()) if h==0:break for i in range(h): if i%2==0:print("".join(['#' if i%2==0 else '.' for i in range(w)])) else:print("".join(['.' if i%2==0 else '#' for i in range(w)])) print() ```
output
1
73,292
23
146,585
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,293
23
146,586
"Correct Solution: ``` while True: h, w = map(int, input().split()) if h == 0 and w == 0: break for i in range(1, h+1): if i % 2 == 0: print(('.#'*w)[:w]) else: print(('#.'*w)[:w]) print() ```
output
1
73,293
23
146,587
Provide a correct Python 3 solution for this coding contest problem. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# #
instruction
0
73,294
23
146,588
"Correct Solution: ``` while True: H,W = map(int, input().split()) if H == 0 and W == 0: break for i in range(H): for j in range(W): if(i+j)%2 == 0: print('#',end="") else: print('.',end="") print() print() ```
output
1
73,294
23
146,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` # coding: utf-8 board = ['#', '.'] while True: h, w = map(int, input().split()) if h == 0 and w == 0: exit() for row in range(h): for column in range(w): print(board[(row + column) % 2], end='') print() print() ```
instruction
0
73,295
23
146,590
Yes
output
1
73,295
23
146,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` while True: h, w = map(int, input().split()) if h == 0 and w == 0: break for i in range(h): for j in range(w): print('#.'[(i + j) & 1], end='') print() print() ```
instruction
0
73,296
23
146,592
Yes
output
1
73,296
23
146,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` while True: H, W = map(int, input().split()) if W == 0 and H == 0: break a_array = "#." * max(H, W) for i in range(H): print (a_array[i % 2: W + i % 2]) print () ```
instruction
0
73,297
23
146,594
Yes
output
1
73,297
23
146,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` while True: H,W=[int(i) for i in input().split(" ")] if H==W==0: break for h in range(H): s="#" if h%2==0 else "." for w in range(W-1): s+="#" if s[-1]=="." else "." print(s) print() ```
instruction
0
73,298
23
146,596
Yes
output
1
73,298
23
146,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` pattern = { 0:["#", "."], 1:[".", "#"], } while True: (H, W) = [int(i) for i in input().split()] if H == W == 0: break for i in range(H): p = pattern[i % 2] print ("join([p[i % 2] for i in range(W)])) print() ```
instruction
0
73,299
23
146,598
No
output
1
73,299
23
146,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` while(True): H, W = map(int, input().split()) if(H == 0 and W == 0): break else: fir = "#" sec = "." for i in range(H): for k in range(W): if k%2: print(fir, end = "") else: print(sec, end = "") print("") tmp = fir fir = sec sec = tmp print("") ```
instruction
0
73,300
23
146,600
No
output
1
73,300
23
146,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` # Print a Chessboard end = 0 while end == 0: rectangle = [int(i) for i in input().rstrip().split()] height = rectangle[0] width = rectangle[1] if [height, width] == [0, 0]: end += 1 else: for i in range(height): for j in range(width): sum = i + j if sum % 2 == 0: print('#', end = "") elif sum % 2 == 1: print('.', end = "") print() ```
instruction
0
73,301
23
146,602
No
output
1
73,301
23
146,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero). Output For each dataset, print the chessboard made of '#' and '.'. Print a blank line after each dataset. Example Input 3 4 5 6 3 3 2 2 1 1 0 0 Output #.#. .#.# #.#. #.#.#. .#.#.# #.#.#. .#.#.# #.#.#. #.# .#. #.# #. .# # Submitted Solution: ``` while True: H,W = map(int,input().split()) if H==W==0: break num = H * W for i in range(0,num): if i % 2 == 0: for j in range(0,W): if j % 2 == 0: print("#") if j % 2 == 1: print(".") if i % 2 == 1: for j in range(0,W): if j % 2 == 0: print(".") if j % 2 == 1: print("#") print() ```
instruction
0
73,302
23
146,604
No
output
1
73,302
23
146,605
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,490
23
146,980
Tags: brute force, geometry, math Correct Solution: ``` from sys import stdin, stdout from itertools import permutations as p from itertools import combinations as com def sqr_or_rec(a, b, c, d): x = ((a[1] - b[1])**2 + (a[0] - b[0]) **2) y = ((c[1] - b[1])**2 + (c[0] - b[0]) **2) w = ((c[1] - d[1])**2 + (c[0] - d[0]) **2) z = ((a[1] - d[1])**2 + (a[0] - d[0]) **2) hypo1 = ((a[1] - c[1])**2 + (a[0] - c[0]) **2) hypo2 = ((b[1] - d[1])**2 + (b[0] - d[0]) **2) if len(set([x,y,w,z])) == 1 and hypo1 == x + y and hypo2 == hypo1 and hypo2 == w + z: return 0 elif len(set([x,y,w,z])) == 2 and hypo1 == x + y and hypo2 == hypo1 and hypo2 == w + z: return 1 else: return -1 x = [] for i in range(8): l, m = map(int, input().split()) x.append([l, m]) sqr, rec = [], [] for g in p(list(range(8)), 4): a, b, c, d = x[g[0]], x[g[1]], x[g[2]], x[g[3]] if sqr_or_rec(a,b,c,d) == 0: y = sorted(g) if y not in sqr: sqr.append(y) elif sqr_or_rec(a,b,c,d) == 1: y = sorted(g) if y not in rec: rec.append(y) if len(sqr) == 0 or (len(sqr) == 1 and len(rec) == 0): print("NO") else: if len(sqr) >= 2: for q in com(sqr, 2): if len(set(q[0] + q[1])) == 8: print("YES") for k in sqr[0]: stdout.write(str(k+1)+" ") print() for k in sqr[1]: stdout.write(str(k+1)+" ") print() exit() for q in rec: if len(set(q + sqr[0])) == 8: print("YES") for k in sqr[0]: stdout.write(str(k+1)+" ") print() for k in q: stdout.write(str(k+1)+" ") print() exit() print("NO") # Made By Mostafa_Khaled ```
output
1
73,490
23
146,981
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,491
23
146,982
Tags: brute force, geometry, math Correct Solution: ``` from itertools import permutations as p l = [list(map(int, input().split())) + [_] for _ in range(1, 9)] def dist(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 def rect(a, b, c, d): return dist(a, b) == dist(c, d) and dist(a, c) == dist(b, d) and dist(a, d) == dist(b, c) and dist(a, b) * dist(b, c) != 0 def sq(a, b, c, d): return rect(a, b, c, d) and dist(a, b) == dist(b, c) for t in p(l): if sq(*t[:4]) and rect(*t[4:]): print("YES") print(' '.join([str(_[2]) for _ in t[:4]])) print(' '.join([str(_[2]) for _ in t[4:]])) exit() print("NO") ```
output
1
73,491
23
146,983
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,492
23
146,984
Tags: brute force, geometry, math Correct Solution: ``` from itertools import combinations, permutations from math import sqrt EPS = 1e-6 def sd(x, y): return ((x[0] - y[0])**2 + (x[1] - y[1])**2) def is_square(points): for perm in permutations(points): if sd(perm[0], perm[1]) == sd(perm[1], perm[2]) == \ sd(perm[2], perm[3]) == sd(perm[3], perm[0]) and \ sd(perm[0], perm[2]) == 2 * sd(perm[0], perm[1]) and \ sd(perm[1], perm[3]) == 2 * sd(perm[0], perm[1]) and \ sqrt(sd(perm[0], perm[1])) * sqrt(sd(perm[1], perm[2])) > EPS: return True return False def is_rect(points): for perm in permutations(points): if sd(perm[0], perm[1]) == sd(perm[2], perm[3]) and \ sd(perm[1], perm[2]) == sd(perm[3], perm[0]) and \ sd(perm[0], perm[2]) == sd(perm[0], perm[1]) + sd(perm[1], perm[2]) and \ sd(perm[1], perm[3]) == sd(perm[1], perm[2]) + sd(perm[2], perm[3]) and \ sqrt(sd(perm[0], perm[1])) * sqrt(sd(perm[1], perm[2])) > EPS: return True return False AMOUNT = 8 points = [] for _ in range(AMOUNT): points += [list(map(int, input().split()))] found = False to_choose = list(range(AMOUNT)) for for_square in combinations(to_choose, r=4): square, rect = [], [] for i in range(AMOUNT): if i in for_square: square += [points[i]] else: rect += [points[i]] if is_square(square) and is_rect(rect): print("YES") print(' '.join(map(lambda x: str(x + 1), for_square))) print(' '.join(map(lambda x: str(x + 1), [y for y in range(AMOUNT) if y not in for_square]))) found = True break if not found: print("NO") ```
output
1
73,492
23
146,985
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,493
23
146,986
Tags: brute force, geometry, math Correct Solution: ``` import sys import math MAX = 100000000000000000000000 def is_inverse(a, b): if b == 0: return a == MAX or a == -MAX if a == 0: return b == MAX or b == -MAX if a == MAX or a == -MAX: return b == 0 or b == -0 if b == MAX or b == -MAX: return a == 0 or a == -0 return a == -(1/b) def slope(a, b): a -= 1 b -= 1 y1, y2 = pts[a][1], pts[b][1] x1, x2 = pts[a][0], pts[b][0] dx = x1 - x2 dy = y1 - y2 if dx == 0: return MAX return dy / dx def dist(a, b): a -= 1 b -= 1 y1, y2 = pts[a][1], pts[b][1] x1, x2 = pts[a][0], pts[b][0] dx = x1 - x2 dy = y1 - y2 return dx**2 + dy**2 def is_valid_square(vals): first, second, third, fourth = vals[0], vals[1], vals[2], vals[3] points = [first, second, third, fourth] for i in points: for j in [x for x in points if x != i]: for k in [z for z in points if z != i and z != j]: for l in [y for y in points if y != j and y != k and y != i]: if slope(i, j) == slope(k, l) and \ is_inverse(slope(i, k), slope(i, j)) and \ dist(i, j) == dist(i, k) == dist(k, l) == dist(j, l): return True return False def is_valid_rectangle(vals): first, second, third, fourth = vals[0], vals[1], vals[2], vals[3] points = [first, second, third, fourth] for i in points: for j in [x for x in points if x != i]: for k in [z for z in points if z != i and z != j]: for l in [y for y in points if y != j and y != k and y != i]: if slope(i, j) == slope(k, l) and \ is_inverse(slope(i, k), slope(i, j)) and \ dist(i, j) == dist(k, l) and dist(i, k) == dist(j, l): return True return False def partition_pts(cur_set): if len(cur_set) == 4: square_set, rect_set = cur_set, [x for x in range(1, 9) if x not in cur_set] if is_valid_square(cur_set) and \ is_valid_rectangle(rect_set): print("YES") r1, r2 = "", "" for x in cur_set: r1 += str(x) + " " for x in rect_set: r2 += str(x) + " " print(r1) print(r2) sys.exit(0) else: return for i in [x for x in range(1, 9) if x not in cur_set]: partition_pts(cur_set + [i]) pts = [] for i in range(8): pts.append([int(x) for x in sys.stdin.readline().split()]) partition_pts([]) print("NO") ```
output
1
73,493
23
146,987
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,494
23
146,988
Tags: brute force, geometry, math Correct Solution: ``` # from decimal import * # getcontext().prec=16 # from math import sqrt # from scipy.special import binom # from collections import defaultdict from math import sin,pi from copy import deepcopy def check(a,b,c): liste=[[a,b,c],[b,c,a],[b,a,c]] for element in liste: a,b,c=element if (b[0]-a[0])*(c[0]-b[0])+(b[1]-a[1])*(c[1]-b[1])==0: return True return False def check_square(liste): a,b,c=liste liste=[[a,b,c],[b,c,a],[b,a,c]] for element in liste: a,b,c=element if ( (b[0]-a[0])**2+(b[1]-a[1])**2 )==( (b[0]-c[0])**2+(b[1]-c[1])**2 ): return True return False tempo=[0 for i in range(8)] perm=[] for i in range(5): tempo[i]=1 for j in range(i+1,6): tempo[j]=1 for k in range(j+1,7): tempo[k]=1 for l in range(k+1,8): tempo[l]=1 copy=deepcopy(tempo) perm.append(copy) tempo[l]=0 tempo[k]=0 tempo[j]=0 tempo[i]=0 entry=[] for i in range(8): x,y=list(map(int,input().split(" "))) entry.append((x,y)) bool=False for permutation in perm: first_set=[] second_set=[] for i in range(8): if permutation[i]==1: first_set.append(entry[i]) else: second_set.append(entry[i]) a,b,c,d=first_set w,x,y,z=second_set if check(a,b,c) and check(b,c,d) and check(c,d,a): if check(w,x,y) and check(x,y,z) and check(y,z,w): if check_square(first_set[:-1]): bool=True elif check_square(second_set[:-1]): first_set,second_set=second_set,first_set bool=True if bool: break if not bool: print("NO") else: index_square=[] index_rectangle=[] for element in first_set: index_square.append(str(entry.index(element)+1)) for element in second_set: index_rectangle.append(str(entry.index(element)+1)) print('YES\n'+(" ").join(index_square)+'\n'+(' ').join(index_rectangle)) ```
output
1
73,494
23
146,989
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,495
23
146,990
Tags: brute force, geometry, math Correct Solution: ``` import math from itertools import permutations def dist_cube(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 def area(x1, y1, x2, y2, x3, y3): return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))) def in_triangle(x1, y1, x2, y2, x3, y3, x, y): A = area(x1, y1, x2, y2, x3, y3) A1 = area(x, y, x2, y2, x3, y3) A2 = area(x1, y1, x, y, x3, y3) A3 = area(x1, y1, x2, y2, x, y) #print(abs(A - (A1 + A2 + A3))) return abs(A - (A1 + A2 + A3)) < 0.000001 class CodeforcesTask135BSolution: def __init__(self): self.result = '' self.points = [] def read_input(self): for x in range(8): self.points.append([int(y) for y in input().split(" ")]) def process_task(self): sol = [] for perm in permutations([x + 1 for x in range(8)]): sq = [] for p in perm[:4]: sq.append(self.points[p - 1]) rc = [] for p in perm[4:]: rc.append(self.points[p - 1]) sq_dists = [dist_cube(sq[0], sq[1]), dist_cube(sq[1], sq[2]), dist_cube(sq[2], sq[3]), dist_cube(sq[3], sq[1]), dist_cube(sq[0], sq[2]), dist_cube(sq[0], sq[3])] rc_dists = [dist_cube(rc[0], rc[1]), dist_cube(rc[1], rc[2]), dist_cube(rc[2], rc[3]), dist_cube(rc[3], rc[1]), dist_cube(rc[0], rc[2]), dist_cube(rc[0], rc[3])] sq_cnt = [sq_dists.count(x) for x in list(set(sq_dists))] sq_cnt.sort(reverse=True) rc_cnt = [rc_dists.count(x) for x in list(set(rc_dists))] rc_cnt.sort(reverse=True) if len(set(sq_dists)) == 2 and sq_cnt[0] == 4 and sq_cnt[1] == 2 and ((rc_cnt == [4, 2] and 2 == len(set(rc_dists))) or (len(set(rc_dists)) == 3 and rc_cnt == [2, 2, 2])): if len(set(rc_dists)) == 3 and rc_cnt == [2, 2, 2]: do_ = False for j in range(4): rcc = rc[:j] + rc[j + 1:] #print(rcc, rc[j], in_triangle(rcc[0][0], rcc[0][1], rcc[1][0], rcc[1][1], rcc[2][0], rcc[2][1], rc[j][0], rc[j][1])) if in_triangle(rcc[0][0], rcc[0][1], rcc[1][0], rcc[1][1], rcc[2][0], rcc[2][1], rc[j][0], rc[j][1]): do_ = True break if not do_: sol = perm break else: sol = perm break if sol: self.result = "YES\n{0}\n{1}".format(" ".join([str(x) for x in sol[:4]]), " ".join([str(x) for x in sol[4:]])) else: self.result = "NO" def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask135BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result()) ```
output
1
73,495
23
146,991
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,496
23
146,992
Tags: brute force, geometry, math Correct Solution: ``` def L(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 def fs(a, b, c, d): return L(a, b) == L(b, c) == L(c, d) == L(d, a) == L(a, c) / 2 def fr(a, b, c, d): return L(a, b) == L(c, d) and L(b, c) == L(d, a) and L(a, c) == L(b, d) def gs(a, b, c, d): return fs(a, b, c, d) or fs(a, b, d, c) or fs(a, c, b, d) def gr(a, b, c, d): return fr(a, b, c, d) or fr(a, b, d, c) or fr(a, c, b, d) def hr(q): return gr(t[q[0]], t[q[1]], t[q[2]], t[q[3]]) t = [(0, 0)] + [list(map(int, input().split())) for i in range(8)] p = {1, 2, 3, 4, 5, 6, 7, 8} for i in range(1, 6): for j in range(i + 1, 7): for k in range(j + 1, 8): for l in range(k + 1, 9): if gs(t[i], t[j], t[k], t[l]): q = list(p - {i, j, k, l}) if hr(q): print('YES') print(i, j, k, l) print(' '.join(map(str, q))) exit(0) print('NO') ```
output
1
73,496
23
146,993
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.
instruction
0
73,497
23
146,994
Tags: brute force, geometry, math Correct Solution: ``` from math import * def a(x1,y1,x2,y2,x3,y3,x4,y4): b=sorted([[x1,y1],[x2,y2],[x3,y3],[x4,y4]]) x1,y1=b[0] x2,y2=b[1] x3,y3=b[2] x4,y4=b[3] a1=sqrt((x1-x2)**2+(y1-y2)**2) a2=sqrt((x4-x2)**2+(y4-y2)**2) a3=sqrt((x4-x3)**2+(y4-y3)**2) a4=sqrt((x1-x3)**2+(y1-y3)**2) return a1==a2==a3==a4 and a1!=0 and a4!=0 and abs(abs(degrees(asin((y2-y1)/a1)-asin((y3-y1)/a4)))-90)<=10**(-8) def b(x1,y1,x2,y2,x3,y3,x4,y4): b=sorted([[x1,y1],[x2,y2],[x3,y3],[x4,y4]]) x1,y1=b[0] x2,y2=b[1] x3,y3=b[2] x4,y4=b[3] a1=sqrt((x1-x2)**2+(y1-y2)**2) a2=sqrt((x4-x2)**2+(y4-y2)**2) a3=sqrt((x4-x3)**2+(y4-y3)**2) a4=sqrt((x1-x3)**2+(y1-y3)**2) return a1==a3 and a2==a4 and a1!=0 and a4!=0 and abs(abs(degrees(asin((y2-y1)/a1)-asin((y3-y1)/a4)))-90)<=10**(-8) c=[list(map(int,input().split())) for i in range(8)] z=False for i in range(5): for j in range(i+1,6): for k in range(j+1,7): for l in range(k+1,8): if a(*c[i]+c[j]+c[k]+c[l]): d=[] e=[] for m in range(8): if m not in [i,j,k,l]: d+=c[m] e.append(m+1) if b(*d): print('YES') print(i+1,j+1,k+1,l+1) print(*e) z=True break if z: break if z: break if z: break if not(z): print('NO') ```
output
1
73,497
23
146,995
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` from itertools import permutations as p l = [list(map(int, input().split())) + [_] for _ in range(1, 9)] def dist(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 def rect(a, b, c, d): return dist(a, b) == dist(c, d) and dist(a, c) == dist(b, d) and dist(a, d) == dist(b, c) and dist(a, b) * dist(b, c) != 0 def sq(a, b, c, d): # print(rect(a, b, c, d)) return rect(a, b, c, d) and dist(a, b) == dist(b, c) for t in p(l): if sq(*t[:4]) and rect(*t[4:]): print("YES") print(' '.join([str(_[2]) for _ in t[:4]])) print(' '.join([str(_[2]) for _ in t[4:]])) exit() print("NO") ```
instruction
0
73,498
23
146,996
Yes
output
1
73,498
23
146,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` from itertools import combinations def get_center(points): center = [] for d in range(len(points[0])): c = sum(p[d] for p in points) center.append(c / 4) return tuple(center) def all_the_same(xs): if len(xs) <= 1: return True first, *ys = xs return all(y == first for y in ys) def distance(p1, p2): return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 def all_distance(points): stack = list(points) distances = [] while len(stack) > 1: point = stack.pop() distances.extend([distance(point, p) for p in stack]) return distances def is_rect(points): center = get_center(points) l = [distance(center, p) for p in points] return all_the_same(l) def is_sqr(points): if not is_rect(points): return False distances = all_distance(points) distances.sort() return all_the_same(distances[:-2]) def main(points): idcs = list(range(0, 8)) for group in combinations(idcs, 4): xs = [points[i] for i in group] ys = [points[i] for i in idcs if i not in group] if is_rect(xs) and is_rect(ys): if is_sqr(xs): print('YES') print(' '.join([str(i+1) for i in group])) print(' '.join([str(i+1) for i in idcs if i not in group])) break elif is_sqr(ys): print('YES') print(' '.join([str(i+1) for i in idcs if i not in group])) print(' '.join([str(i+1) for i in group])) break else: print('NO') all_points = [] for _ in range(8): all_points.append(list(map(int, input().split()))) main(all_points) ```
instruction
0
73,499
23
146,998
Yes
output
1
73,499
23
146,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` import itertools import math import os import sys eps = 1e-8 coord = [[]] + [list(map(int, input().split())) for _ in range(8)] idx = list(range(1, 9)) def perpendicular(v1, v2): return sum([x * y for (x, y) in zip(v1, v2)]) < eps def all_perpendicular(vs): return all([perpendicular(vs[i], vs[(i+1)%4]) for i in range(4)]) def rect_sides(vs): ls = list(map(lambda v: math.hypot(*v), vs)) return abs(ls[0] - ls[2]) < eps and abs(ls[1] - ls[3]) < eps def square_sides(vs): ls = list(map(lambda v: math.hypot(*v), vs)) l = ls[0] for lx in ls: if abs(lx - l) > eps: return False return True def coords_to_vecs(cs): return [ [cs[(i+1)%4][0] - cs[i][0], cs[(i+1)%4][1] - cs[i][1]] for i in range(4)] def is_square(coords): for p in itertools.permutations(coords): vs = coords_to_vecs(p) if all_perpendicular(vs) and square_sides(vs): return True return False def is_rect(coord): for p in itertools.permutations(coord): vs = coords_to_vecs(p) if all_perpendicular(vs) and rect_sides(vs): return True return False for comb in itertools.combinations(idx, 4): fsi = list(comb) ssi = list(set(idx) - set(comb)) fs = [coord[i] for i in fsi] ss = [coord[i] for i in ssi] if is_square(fs) and is_rect(ss): print("YES") print(' '.join(map(str, fsi))) print(' '.join(map(str, ssi))) sys.exit(0) if is_square(ss) and is_rect(fs): print("YES") print(' '.join(map(str, ssi))) print(' '.join(map(str, fsi))) sys.exit(0) print("NO") ```
instruction
0
73,500
23
147,000
Yes
output
1
73,500
23
147,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` from sys import stdin, stdout from itertools import permutations as p from itertools import combinations as com def sqr_or_rec(a, b, c, d): x = ((a[1] - b[1])**2 + (a[0] - b[0]) **2) y = ((c[1] - b[1])**2 + (c[0] - b[0]) **2) w = ((c[1] - d[1])**2 + (c[0] - d[0]) **2) z = ((a[1] - d[1])**2 + (a[0] - d[0]) **2) hypo1 = ((a[1] - c[1])**2 + (a[0] - c[0]) **2) hypo2 = ((b[1] - d[1])**2 + (b[0] - d[0]) **2) if len(set([x,y,w,z])) == 1 and hypo1 == x + y and hypo2 == hypo1 and hypo2 == w + z: return 0 elif len(set([x,y,w,z])) == 2 and hypo1 == x + y and hypo2 == hypo1 and hypo2 == w + z: return 1 else: return -1 x = [] for i in range(8): l, m = map(int, input().split()) x.append([l, m]) sqr, rec = [], [] for g in p(list(range(8)), 4): a, b, c, d = x[g[0]], x[g[1]], x[g[2]], x[g[3]] if sqr_or_rec(a,b,c,d) == 0: y = sorted(g) if y not in sqr: sqr.append(y) elif sqr_or_rec(a,b,c,d) == 1: y = sorted(g) if y not in rec: rec.append(y) if len(sqr) == 0 or (len(sqr) == 1 and len(rec) == 0): print("NO") else: if len(sqr) >= 2: for q in com(sqr, 2): if len(set(q[0] + q[1])) == 8: print("YES") for k in sqr[0]: stdout.write(str(k+1)+" ") print() for k in sqr[1]: stdout.write(str(k+1)+" ") print() exit() for q in rec: if len(set(q + sqr[0])) == 8: print("YES") for k in sqr[0]: stdout.write(str(k+1)+" ") print() for k in q: stdout.write(str(k+1)+" ") print() exit() print("NO") ```
instruction
0
73,501
23
147,002
Yes
output
1
73,501
23
147,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` # from decimal import * # getcontext().prec=16 # from math import sqrt # from scipy.special import binom # from collections import defaultdict from math import sin,pi from copy import deepcopy def check(a,b,c): liste=[[a,b,c],[b,c,a],[b,a,c]] for element in liste: a,b,c=element if (b[0]-a[0])*(c[0]-b[0])+(b[1]-a[1])*(c[1]-b[1])==0: return True return False def check_square(liste): a,b,c=liste liste=[[a,b,c],[b,c,a],[b,a,c]] for element in liste: a,b,c=element if ( (b[0]-a[0])**2+(b[1]-a[1])**2 )==( (b[0]-c[0])**2+(b[1]-c[1])**2 ): return True return False tempo=[0 for i in range(8)] perm=[] for i in range(5): tempo[i]=1 for j in range(i+1,6): tempo[j]=1 for k in range(j+1,7): tempo[k]=1 for l in range(k+1,8): tempo[l]=1 copy=deepcopy(tempo) perm.append(copy) tempo[l]=0 tempo[k]=0 tempo[j]=0 tempo[i]=0 entry=[] for i in range(8): x,y=list(map(int,input().split(" "))) entry.append((x,y)) bool=False for permutation in perm: first_set=[] second_set=[] for i in range(8): if permutation[i]==1: first_set.append(entry[i]) else: second_set.append(entry[i]) a,b,c,d=first_set w,x,y,z=second_set if check(a,b,c) and check(b,c,d) and check(c,d,a): if check(w,x,y) and check(x,y,z) and check(y,z,w): if check_square(first_set[:-1]): bool=True elif check_square(second_set[:-1]): first_set,second_set=second_set,first_set bool=True if bool: break if not bool: print("No") else: index_square=[] index_rectangle=[] for element in first_set: index_square.append(str(entry.index(element)+1)) for element in second_set: index_rectangle.append(str(entry.index(element)+1)) print('YES\n'+(" ").join(index_square)+'\n'+(' ').join(index_rectangle)) ```
instruction
0
73,502
23
147,004
No
output
1
73,502
23
147,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` from itertools import combinations def get_center(points): center = [] for d in range(len(points[0])): c = sum(p[d] for p in points) center.append(c / 4) return tuple(center) def all_the_same(xs): if len(xs) <= 1: return True first, *ys = xs return all(y == first for y in ys) def distance(p1, p2): return (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 def all_distance(points): stack = list(points) distances = [] while len(stack) > 1: point = stack.pop() distances.extend([distance(point, p) for p in stack]) return distances def is_rect(points): center = get_center(points) l = [distance(center, p) for p in points] return all_the_same(l) def is_sqr(points): if not is_rect(points): return False distances = all_distance(points) distances.sort() return all_the_same(distances[:-2]) def main(points): idcs = list(range(0, 8)) for group in combinations(idcs, 4): xs = [points[i] for i in group] ys = [points[i] for i in idcs if i not in group] if is_rect(xs) and is_rect(ys): if is_sqr(xs): print('YES') print(' '.join([str(i+1) for i in idcs if i not in group])) print(' '.join([str(i+1) for i in group])) break elif is_sqr(ys): print('YES') print(' '.join([str(i+1) for i in group])) print(' '.join([str(i+1) for i in idcs if i not in group])) break else: print('NO') all_points = [] for _ in range(8): all_points.append(list(map(int, input().split()))) main(all_points) ```
instruction
0
73,503
23
147,006
No
output
1
73,503
23
147,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` import math from itertools import permutations def dist_cube(a, b): return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 class CodeforcesTask135BSolution: def __init__(self): self.result = '' self.points = [] def read_input(self): for x in range(8): self.points.append([int(y) for y in input().split(" ")]) def process_task(self): sol = [] for perm in permutations([x + 1 for x in range(8)]): sq = [] for p in perm[:4]: sq.append(self.points[p - 1]) rc = [] for p in perm[4:]: rc.append(self.points[p - 1]) sq_dists = [dist_cube(sq[0], sq[1]), dist_cube(sq[1], sq[2]), dist_cube(sq[2], sq[3]), dist_cube(sq[3], sq[1]), dist_cube(sq[0], sq[2]), dist_cube(sq[0], sq[3])] rc_dists = [dist_cube(rc[0], rc[1]), dist_cube(rc[1], rc[2]), dist_cube(rc[2], rc[3]), dist_cube(rc[3], rc[1]), dist_cube(rc[0], rc[2]), dist_cube(rc[0], rc[3])] sq_cnt = [sq_dists.count(x) for x in list(set(sq_dists))] sq_cnt.sort(reverse=True) rc_cnt = [rc_dists.count(x) for x in list(set(rc_dists))] rc_cnt.sort(reverse=True) if len(set(sq_dists)) == 2 and 2 <= len(set(rc_dists)) <= 3 and sq_cnt[0] == 4 and sq_cnt[1] == 2 and (rc_cnt == [4, 2] or rc_cnt == [2, 2, 2]): sol = perm break if sol: self.result = "YES\n{0}\n{1}".format(" ".join([str(x) for x in sol[:4]]), " ".join([str(x) for x in sol[4:]])) else: self.result = "NO" def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask135BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result()) ```
instruction
0
73,504
23
147,008
No
output
1
73,504
23
147,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case. Input You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide. Output Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct. If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed. Examples Input 0 0 10 11 10 0 0 11 1 1 2 2 2 1 1 2 Output YES 5 6 7 8 1 2 3 4 Input 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 Output NO Input 0 0 4 4 4 0 0 4 1 2 2 3 3 2 2 1 Output YES 1 2 3 4 5 6 7 8 Note Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes. Submitted Solution: ``` from itertools import permutations def is_rectangle(a, b, c, d): ab = (b[0]-a[0], b[1]-a[1]) ad = (d[0]-a[0], d[1]-a[1]) dp = ab[0]*ad[0] + ab[1]*ad[1] ne = len(set((a, b, c, d))) == 4 return ne and dp == 0 and (a[0]+ab[0]+ad[0], a[1]+ab[1]+ad[1]) == c def is_square(a, b, c, d): abl = (b[0]-a[0])**2 + (b[1]-a[1])**2 adl = (d[0]-a[0])**2 + (d[1]-a[1])**2 return abl == adl and is_rectangle(a, b, c, d) def is_rectangle_perm(a, b, c, d): for p in permutations((a, b, c, d)): if is_rectangle(*p): return True return False def is_square_perm(a, b, c, d): for p in permutations((a, b, c, d)): if is_rectangle(*p): return True return False ps = [] for i in range(8): ps.append(tuple(map(int, input().split()))) possible = False for i in range(0, 8): for j in range(i+1, 8): for k in range(j+1, 8): for l in range(k+1, 8): g0 = set(ps) g1 = set((ps[i], ps[j], ps[k], ps[l])) g2 = g0 - g1 possible = is_rectangle_perm(*g1) and is_square_perm(*g2) possible = is_rectangle_perm(*g2) and is_square_perm(*g1) print("YES" if possible else "NO") ```
instruction
0
73,505
23
147,010
No
output
1
73,505
23
147,011