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
Provide tags and a correct Python 3 solution for this coding contest problem. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675
instruction
0
44,981
23
89,962
Tags: geometry Correct Solution: ``` from decimal import * from math import sin , pi , sqrt def getRadian( x ): return x*Decimal(pi)/180 def area( a , b , c ): p = (a+b+c)/2 return Decimal( sqrt( p*(p-a)*(p-b)*(p-c) ) ) if __name__ == "__main__": getcontext().prec = 100 n , r = map( Decimal , input().split() ) beta = 90/n beta_radian = getRadian( beta ) #print( beta_radian ) gamma = 180/n gamma_radian = getRadian( gamma ) #print( gamma_radian ) S = r*r*Decimal(sin(beta_radian))*Decimal(sin(gamma_radian))/Decimal(sin(beta_radian+gamma_radian)) print(n*S) ```
output
1
44,981
23
89,963
Provide tags and a correct Python 3 solution for this coding contest problem. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675
instruction
0
44,982
23
89,964
Tags: geometry Correct Solution: ``` from math import pi, sin, tan def zvezda(n, r): alpha = (2 * pi) / n s1 = r * r * sin(alpha * 0.5) * sin(alpha * 0.5) / tan(0.5 * (alpha + 0.5 * alpha)) s2 = 0.5 * (alpha - sin(alpha)) * r * r s3 = pi * r * r return format(s3 - n * (s2 + s1), '.10f') N, R = [int(j) for j in input().split()] print(zvezda(N, R)) ```
output
1
44,982
23
89,965
Provide tags and a correct Python 3 solution for this coding contest problem. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675
instruction
0
44,983
23
89,966
Tags: geometry Correct Solution: ``` import math n, R = [int(x) for x in input().split()] phi = math.pi/(2*n) A = math.sin(2*phi) * (math.cos(2*phi) - math.sin(2*phi) * math.tan(math.pi/2 - 3*phi)) print(n*R*R*A) ```
output
1
44,983
23
89,967
Provide tags and a correct Python 3 solution for this coding contest problem. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675
instruction
0
44,984
23
89,968
Tags: geometry Correct Solution: ``` from math import * pi = 3.141592653589793238462643383279502884197 n, r = map(int, input().split()) a = tan(pi/(2*n)) b = tan(pi/n) a = 1/a + 1/b print(r*r/a*n) ```
output
1
44,984
23
89,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` import math n,r = map(int,input().split()) a = math.pi/n b = a/2 c = math.pi-a-b side = r*math.sin(a)/(2*math.sin(c)) area = 0.5*math.sin(b)*side*r*n*4 print(area) ```
instruction
0
44,985
23
89,970
Yes
output
1
44,985
23
89,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` import math n, r = map(int, input().split()) print(n * r * r / (1 / math.tan(math.pi / (2*n)) + 1 / math.tan(math.pi/n))) ```
instruction
0
44,986
23
89,972
Yes
output
1
44,986
23
89,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` import math p,r = map(int,input().split() ) print((math.sin(math.pi/p)**2 /math.tan(1.5*math.pi/p) - math.sin(2*math.pi/p)/2)*-r*r*p) ```
instruction
0
44,987
23
89,974
Yes
output
1
44,987
23
89,975
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` import math ln = input().split(" ") n = int(ln[0]) r = int(ln[1]) tot_area = n / 2 * (math.sin(2 * math.pi / n)) * r * r if n < 10 ** 6: x = (1 - math.cos(2 * math.pi / n)) / (1 - math.cos(3 * math.pi / n)) else: x = 4 / 9 x *= r ** 2 small_area = n / 2 * math.sin(3 * math.pi / n) * x print(tot_area - small_area) ```
instruction
0
44,988
23
89,976
Yes
output
1
44,988
23
89,977
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` #!/usr/bin/python3 import math class Vector: def __init__(self, x, y): self.x = x self.y = y def length(self): return math.hypot(self.x, self.y) def dot(self, other): return self.x * other.x + self.y * other.y def angleWith(self, other): return math.acos( self.dot(other) / (self.length() * other.length()) ) def normalize(self): self /= self.length() def normalized(self): return self / self.length() def rotate(self, angle): sine = math.sin(angle) cosine = math.cos(angle) x = self.x * cosine - self.y * sine y = self.x * sine + self.y * cosine self.x = x self.y = y def rotated(self, angle): sine = math.sin(angle) cosine = math.cos(angle) x = self.x * cosine - self.y * sine y = self.x * sine + self.y * cosine return Vector(x, y) def __iadd__(self, other): self.x += other.x self.y += other.y return self def __isub__(self, other): self.x -= other.x self.y -= other.y return self def __add__(self, other): return Vector(self.x + other.x, self.y + other.y) def __sub__(self, other): return Vector(self.x - other.x, self.y - other.y) def __imul__(self, other): self.x *= other self.y *= other return self def __itruediv__(self, other): self.x /= other self.y /= other return self def __mul__(self, other): return Vector(self.x * other, self.y * other) def __truediv__(self, other): return Vector(self.x / other, self.y / other) def __neg__(self): return Vector(-self.x, -self.y) def __str__(self): return str(self.x) + ' ' + str(self.y) # return "{:.2f} {:.2f}".format(self.x, self.y) def point_coord(n, r, i): d_angle = 2*math.pi / n return Vector(0, r).rotated(-i*d_angle) # def line_intersection(p0, p1, p2, p3): # # xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0]) # # ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) # dx = (p0.x - p2.x, p1.x - p3.x) # dy = (p0.y - p2.y, p1.y - p3.y) # def det(a, b): # return a[0] * b[1] - a[1] * b[0] # div = det(dx, dy) # if div == 0: # raise Exception('lines do not intersect') # line1 = ((p0.x, p0.y), (p1.x, p1.y)) # line2 = ((p2.x, p2.y), (p3.x, p3.y)) # d = ( det(*line1), det(*line2) ) # x = det(d, dx) / div # y = det(d, dy) / div # return Vector(x, y) def line_intersection(line1, line2): xdiff = (line1[0][0] - line1[1][0], line2[0][0] - line2[1][0]) ydiff = (line1[0][1] - line1[1][1], line2[0][1] - line2[1][1]) #Typo was here def det(a, b): return a[0] * b[1] - a[1] * b[0] div = det(xdiff, ydiff) if div == 0: raise Exception('lines do not intersect') d = (det(*line1), det(*line2)) x = det(d, xdiff) / div y = det(d, ydiff) / div return x, y # print(line_intersection(((0,0), (4,4)), ((1,3), (3,1)))) # print(line_intersection(Vector(0,0), Vector(4,4), Vector(1,3), Vector(3,1))) n, r = [int(i) for i in input().split()] # n = 7 # r = 10 from1 = 0 from2 = 1 to1 = n//2 to2 = to1 + 2 p0 = point_coord(n, r, from1) p1 = point_coord(n, r, from2) p2 = point_coord(n, r, to1) p3 = point_coord(n, r, to2) v1 = p2 - p0 v2 = p3 - p1 phi = v1.angleWith(v2) # omega = math.pi - phi # print(phi) line1 = ((p0.x, p0.y), (p2.x, p2.y)) line2 = ((p1.x, p1.y), (p3.x, p3.y)) # p_int =line_intersection(p0, p1, p2, p3) x,y =line_intersection(line1, line2) p_int = Vector(x, y) # print(p_int) d = (p_int - p0).length() # print(d) # print() s = 0.5 * d*d * phi # print(s) # print(n*s) print(math.pi*r*r - n*s) ```
instruction
0
44,989
23
89,978
No
output
1
44,989
23
89,979
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` s = input() n, r = map(int, s.split()) pi = 3.141592653589793238 ug = pi / n from math import sin from math import cos ug1 = ug * (n // 2 - 1) ug2 = pi / 2 - ug st = cos(ug2) * r * 2 seg = pi * r * r - r * r * sin(2 * ug) * n / 2 S = st * st / cos(ug1) * sin(ug1) / 4 S = S * n S = pi * r * r - S - seg print(S) ```
instruction
0
44,990
23
89,980
No
output
1
44,990
23
89,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` from math import sin, pi, cos n, r = map(int, input().split()) A = n * (r*r/2*sin(2*pi/n)) #print(A) alp = 2*pi/n t = -sin(alp) / (sin(pi+alp/2) - sin(alp)) x = cos(alp) + (cos(pi+alp/2) - cos(alp)) * t x = abs(x*r) #print(x) s = (r**2 + r**2 - 2*r*r*cos(alp))**.5 A -= n*s*(r*abs(cos(alp/2))-x)/2 print(A) ```
instruction
0
44,991
23
89,982
No
output
1
44,991
23
89,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It was decided in IT City to distinguish successes of local IT companies by awards in the form of stars covered with gold from one side. To order the stars it is necessary to estimate order cost that depends on the area of gold-plating. Write a program that can calculate the area of a star. A "star" figure having n ≥ 5 corners where n is a prime number is constructed the following way. On the circle of radius r n points are selected so that the distances between the adjacent ones are equal. Then every point is connected by a segment with two maximally distant points. All areas bounded by the segments parts are the figure parts. <image> Input The only line of the input contains two integers n (5 ≤ n < 109, n is prime) and r (1 ≤ r ≤ 109) — the number of the star corners and the radius of the circumcircle correspondingly. Output Output one number — the star area. The relative error of your answer should not be greater than 10 - 7. Examples Input 7 10 Output 108.395919545675 Submitted Solution: ``` from math import sin, pi, tan, degrees # n, r = 999999937, 1 # n, r = 6, 20 n, r = [int(x) for x in input().split()] # aoc = pi/n # cao = pi/(2*n) # aco = (4*n-3)*pi/(2*n) # print('vinklar', aoc, cao, aco) # ao = r # co = sin(cao)*ao/sin(aco) # ac = sin(aoc)*ao/sin(aco) # s = (ac+ao+co)/2 # print(s) # print(ao, co, ac, ac+co) # print(s, (s-ac), (s-ao), (s-co)) # print(2*n*(s*(s-ac)*(s-ao)*(s-co))**0.5) # print(degrees(pi/n)) # print(pi/n) # print(tan(pi/n)) area_t = r/2 * r/2 * tan(pi/n) print(2*n*area_t) ```
instruction
0
44,992
23
89,984
No
output
1
44,992
23
89,985
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S. Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious reason, had no success in that. Please help Alyona construct such triangle. Please note that vertices of resulting triangle are not necessarily chosen from n given points. Input In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points. The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108) — coordinates of ith point. It is guaranteed that there is at least one triple of points not lying on the same line. Output Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S. Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by absolute value. It is guaranteed that there is at least one desired triangle. If there is more than one answer, print any of them. Example Input 4 1 0 0 1 0 0 1 1 1 Output -1 0 2 0 0 2 Note <image> Submitted Solution: ``` n, s = map(int, input().split()) xmin, ymin, xmax, ymax = 10 ** 9, 10 ** 9, -10 ** 9, -10 ** 9 data = [None for i in range(n)] for i in range(n): xi, yi = map(int, input().split()) xmin = min(xmin, xi) ymin = min(ymin, yi) xmax = max(xmax, xi) ymax = max(ymax, yi) data[i] = [yi, xi] data.sort() x1, y1, x2, y2, x3, y3 = None, None, None, None, None, None if data[-1][0] == data[-2][0]: y1 = data[-1][0] + 1 x1 = xmax x2, y2 = xmin, ymin x3, y3 = xmax, ymin print() print(x1, y1) print(x2 - 1, y2) print(x3, y3) ```
instruction
0
45,009
23
90,018
No
output
1
45,009
23
90,019
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which area exceeds S. Alyona tried to construct a triangle with integer coordinates, which contains all n points and which area doesn't exceed 4S, but, by obvious reason, had no success in that. Please help Alyona construct such triangle. Please note that vertices of resulting triangle are not necessarily chosen from n given points. Input In the first line of the input two integers n and S (3 ≤ n ≤ 5000, 1 ≤ S ≤ 1018) are given — the number of points given and the upper bound value of any triangle's area, formed by any three of given n points. The next n lines describes given points: ith of them consists of two integers xi and yi ( - 108 ≤ xi, yi ≤ 108) — coordinates of ith point. It is guaranteed that there is at least one triple of points not lying on the same line. Output Print the coordinates of three points — vertices of a triangle which contains all n points and which area doesn't exceed 4S. Coordinates of every triangle's vertex should be printed on a separate line, every coordinate pair should be separated by a single space. Coordinates should be an integers not exceeding 109 by absolute value. It is guaranteed that there is at least one desired triangle. If there is more than one answer, print any of them. Example Input 4 1 0 0 1 0 0 1 1 1 Output -1 0 2 0 0 2 Note <image> Submitted Solution: ``` n, s = map(int, input().split()) a = [[0] * 2 for i in range(n)] for i in range(n): a[i][0], a[i][1] = map(int, input().split()) a.sort() x1 = a[0][0] x2 = a[n-1][0] def sort_col(i): return i[1] a.sort(key=sort_col) y1 = a[0][1] y2 = a[n-1][1] if abs((y1-y2)*(x1-x2)) <= 2*s: print(x1,y1) print(x1, y1 + 2*(y2-y1)) print(x1 + 2*(x2-x1), y1) ```
instruction
0
45,010
23
90,020
No
output
1
45,010
23
90,021
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,031
23
90,062
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` l=[list(map(int,input().split())) for _ in range(3)] print(3) for i in range(3): a=l[(i+0)%3] b=l[(i+1)%3] c=l[(i+2)%3] ab=[b[0]-a[0],b[1]-a[1]] ac=[c[0]-a[0],c[1]-a[1]] print(a[0]+ab[0]+ac[0],a[1]+ab[1]+ac[1]) ```
output
1
45,031
23
90,063
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,032
23
90,064
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` ax,ay=map(int,input().split()) bx,by=map(int,input().split()) cx,cy=map(int,input().split()) print(3) print(bx+ax-cx,end=" ") print(by+ay-cy) print(ax+cx-bx,end=" ") print(ay+cy-by) print(bx+cx-ax,end=" ") print(by+cy-ay) ```
output
1
45,032
23
90,065
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,033
23
90,066
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` x1,y1=map(int,input( ).split(" ")) x2,y2=map(int,input( ).split(" ")) x3,y3=map(int,input( ).split(" ")) print(3) print(str(x1+x2-x3)+" "+str(y1+y2-y3)) print(str(x1+x3-x2)+" "+str(y1+y3-y2)) print(str(x2+x3-x1)+" "+str(y2+y3-y1)) ```
output
1
45,033
23
90,067
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,034
23
90,068
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` #!/usr/bin/env python3 def ri(): return map(int, input().split()) x1, y1 = ri() x2, y2 = ri() x3, y3 = ri() print(3) print(x2-x1 + x3, y2-y1 + y3) print(x3-x2 + x1, y3-y2 + y1) print(x1-x3 + x2, y1-y3 + y2) ```
output
1
45,034
23
90,069
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,035
23
90,070
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` I = lambda: map(int, input().split()) x1, y1 = I() x2, y2 = I() x3, y3 = I() A, B, C = complex(x1, y1), complex(x2, y2), complex(x3, y3) print(3) print(int((B + C - A).real), int((B + C - A).imag)) print(int((A + B - C).real), int((A + B - C).imag)) print(int((A + C - B).real), int((A + C - B).imag)) ```
output
1
45,035
23
90,071
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,036
23
90,072
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` # http://codeforces.com/problemset/problem/749/B class Cord(object): def __init__(self, x, y): self.x = x self.y = y def print(self): print('{0} {1}'.format(self.x, self.y)) def __str__(self): return '{0} {1}'.format(self.x, self.y) def get_point(a, b , c): x = a.x - b.x + c.x y = c.y - b.y + a.y return Cord(x,y) def main(): cords = [Cord(0, 0) for i in range(0,3)] res = [0 for i in range(0, 6)] for i in range(0, 3): x, y = map(int, input().split()) cords[i].x = x cords[i].y = y res[0] = get_point(cords[0], cords[1], cords[2]) res[1] = get_point(cords[0], cords[2], cords[1]) res[2] = get_point(cords[1], cords[2], cords[0]) res[3] = get_point(cords[1], cords[0], cords[2]) res[4] = get_point(cords[2], cords[1], cords[0]) res[5] = get_point(cords[2], cords[0], cords[1]) final = [] for i in res: if len(final) == 0: final.append(i) else: flag = False for j in final: if i.x == j.x and i.y == j.y: flag = True break if not flag: final.append(i) print(len(final)) for i in final: i.print() main() ```
output
1
45,036
23
90,073
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,037
23
90,074
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` import math EPSILON = 10 ** -3 class Vector: def __init__(self, d=2, coords=[0, 0]): self.d = d self.coords = coords[:] @staticmethod def fromEnds(p1, p2): n = len(p1) assert n == len(p2) v = [] for i in range(n): v.append(p2[i] - p1[i]) return Vector(n, v) def apply(self, point): return tuple([self.coords[i] + point[i] for i in range(self.d)]) def inverse(self): return Vector(self.d, list(map((lambda x: -x), self.coords))) def __repr__(self): return "Vector[{}] ({})".format(self.d, self.coords) def len(self): return math.sqrt(sum(x * x for x in self.coords)) def __add__(self, other): assert self.d == other.d return Vector(self.d, [self.coords[i] + other.coords[i] for i in range(self.d)]) def __eq__(self, other): return self.d == other.d and self.coords == other.coords def extend(self, k): return Vector(self.d, [x * k for x in self.coords]) def scalmul(self, other): assert self.d == other.d return sum(self.coords[i] * other.coords[i] for i in range(self.d)) def cos(self, other): return self.scalmul(other) / (self.len() * other.len()) def is_ort(self, other): return self.scalmul(other) <= EPSILON def proj_to(self, other): return self.scalmul(other) / other.len() def proj_from(self, other): return other.proj_to(self) t = lambda: tuple(map(int, input().split())) p1, p2, p3 = t(), t(), t() p = [p1, p2, p3] ans = set() for i in range(3): others = [] for _p in p: if _p != p[i]: others.append(_p) assert len(others) == 2 v1 = Vector.fromEnds(others[0], others[1]) v2 = Vector.fromEnds(others[1], others[0]) ans.add(v1.apply(p[i])) ans.add(v2.apply(p[i])) print(len(ans)) for item in ans: print(" ".join(map(str,item))) ```
output
1
45,037
23
90,075
Provide tags and a correct Python 3 solution for this coding contest problem. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram
instruction
0
45,038
23
90,076
Tags: brute force, constructive algorithms, geometry Correct Solution: ``` ax,ay=map(int,input().split()) bx,by=map(int,input().split()) cx,cy=map(int,input().split()) d1x=bx+cx-ax d1y=by+cy-ay d2x=cx+ax-bx d2y=cy+ay-by d3x=ax+bx-cx d3y=ay+by-cy print("3") print(d1x,d1y) print(d2x,d2y) print(d3x,d3y) ```
output
1
45,038
23
90,077
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` [x1,y1]=[int(x) for x in input().split()] [x2,y2]=[int(x) for x in input().split()] [x3,y3]=[int(x) for x in input().split()] print(3) print(x3+x1-x2, y3+y1-y2) print(x3+x2-x1, y3+y2-y1) print(x1+x2-x3, y1+y2-y3) ```
instruction
0
45,039
23
90,078
Yes
output
1
45,039
23
90,079
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` AX,AY = (int(x) for x in input().split(' ')) BX,BY = [int(x) for x in input().split(' ')] CX,CY = [int(x) for x in input().split(' ')] print(3) print( str(AX+BX-CX)+' '+str(AY+BY-CY) ) print( str(AX-BX+CX)+' '+str(AY-BY+CY) ) print( str(BX-AX+CX)+' '+str(BY-AY+CY) ) ```
instruction
0
45,040
23
90,080
Yes
output
1
45,040
23
90,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` def main(): x1,y1=map(int,input().split()) x2, y2 = map(int, input().split()) x3, y3 = map(int, input().split()) print(3) print((x1+x2-x3),(y1+y2-y3)) print((x1+x3-x2),(y1+y3-y2)) print((x2+x3-x1),(y2+y3-y1)) main() ```
instruction
0
45,041
23
90,082
Yes
output
1
45,041
23
90,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` points = [] for i in range(3): points.append(tuple(map(int, input().split()))) ans = set() for i in range(3): for j in range(3): if i == j: continue vector = (points[j][0] - points[i][0], points[j][1] - points[i][1]) third = 0 + 1 + 2 - i - j ans.add((points[third][0] + vector[0], points[third][1] + vector[1])) print(len(ans)) for a, b in ans: print(a, b) ```
instruction
0
45,042
23
90,084
Yes
output
1
45,042
23
90,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` xarr=list() yarr=list() xsum=0 ysum=0 for i in range(3): x,y=map(int,input().split()) xarr.append(x) yarr.append(y) xsum+=x ysum+=y print(xsum,ysum) for i in range(3): print(xsum-2*xarr[i],ysum-2*yarr[i]) ```
instruction
0
45,043
23
90,086
No
output
1
45,043
23
90,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` a,b=map(int,input().split()) c,d=map(int,input().split()) e,f=map(int,input().split()) t=[] k=a-c g=b-d l=e-k r=e+k h=[r,l] t.append(h) l=f-g r=g+f h=[r,l] t.append(h) k=a-e g=b-f l=c-k r=c+k h=[r,l] t.append(h) l=d-g r=g+d h=[r,l] t.append(h) k=e-c g=f-d l=a-k r=a+k h=[r,l] t.append(h) l=b-g r=b+g h=[r,l] t.append(h) m=[] for i in t: if i not in m: m.append(i) print(len(m)) for i in m: print(i[0],i[1]) ```
instruction
0
45,044
23
90,088
No
output
1
45,044
23
90,089
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` l=[] for i in range(3): x,y = map(int,input().split()) l.append([x,y]) print(l) S = set() def calc(a): ans = 0 n = len(a) for i in range(n): ans += a[i][0]*a[(i+1)%n][1] - a[i][1]*a[(i+1)%n][0] return ans for i in range(3): for j in range(3): if i== j: continue for k in range(3): if i==k or i == j: continue x = l[i][0] + l[j][0] - l[k][0] y = l[i][1] + l[j][1] - l[k][1] new = [] new.append(l[i]) new.append(l[k]) new.append(l[j]) new.append([x,y]) if calc(new) > 0: S.add(tuple([x,y])) print(len(S)) for i in S: print(i[0],i[1]) ```
instruction
0
45,045
23
90,090
No
output
1
45,045
23
90,091
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. Input The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. Output First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. Example Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 Note If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Submitted Solution: ``` def Maia(): sx = set() sy = set() Ax = [] Ay = [] x1 ,y1 = map(int, input().split()) Ax.append(x1) Ay.append(y1) x2, y2 = map(int, input().split()) Ax.append(x2) Ay.append(y2) x3, y3 = map(int, input().split()) Ax.append(x3) Ay.append(y3) print(3) dx1 = 0 dy1 = 0 rezx = [] rezy = [] if x1 == x2: dx1 = abs( y1 - y2) dy1 = 1 rezx.append(x3) rezy.append(y3) elif x2 == x3: dx1 = abs( y2 - y3) dy1 = 2 rezx.append(x1) rezy.append(y1) elif x1 == x3: dx1 = abs(y1 - y3) dy1 = 3 rezx.append(x2) rezy.append(y2) elif y1 == y2: dx1 = abs( x1 - x2 ) dy1 = 4 rezy.append(y3) rezx.append(x3) elif y2 == y3: dx1 = abs( x2 - x3 ) dy1 = 5 rezy.append(y1) rezx.append(x1) elif y1 == y3: dx1 = abs( x1 - x3 ) dy1 = 6 rezy.append(y2) rezx.append(x2) X = 0 Y = 0 if 1 <= dy1 <= 3: X = Ay[dy1 - 1] Y = Ax[dy1 - 1] + dx1 aa = Ax[dy1 - 1] - dx1 # print("dvc sdb") print(X, Y) print(X , Ax[dy1 - 1] - dx1) print(rezx[0]*(-1), rezy[0] ) elif 4 <= dy1 <= 6: X = Ax[dy1 - 3 - 1] Y = Ay[dy1 - 3 - 1] + dx1 aa = Ay[dy1 - 3 - 1] - dx1 # print("cv") print(X, Y) print(X, Ay[dy1 - 3 - 1] - dx1) print(rezx[0], rezy[0]*(-1)) if __name__ == '__main__': Maia() ```
instruction
0
45,046
23
90,092
No
output
1
45,046
23
90,093
Provide tags and a correct Python 3 solution for this coding contest problem. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image>
instruction
0
45,135
23
90,270
Tags: geometry, graphs Correct Solution: ``` from decimal import * getcontext().prec = 40 eps = Decimal('1e-10') class Circle: def __init__(self, x, y, r): self.x = x self.y = y self.r = r def contains(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd < (self.r - c.r)**2 and self.r > c.r def in_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r - c.r)**2 and self.r > c.r def ex_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r + c.r)**2 def intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return (self.r - c.r)**2 < dd < (self.r + c.r)**2 def not_intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd > (self.r + c.r)**2 def get_intersections(self, c): x1, y1, r1, x2, y2, r2 = map(Decimal, [self.x, self.y, self.r, c.x, c.y, c.r]) RR = (x1-x2)**2 + (y1-y2)**2 rx1 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry1 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) rx2 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry2 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) return {(rx1, ry1), (rx2, ry2)} def is_on(self, p): return abs((self.x - p[0])**2 + (self.y - p[1])**2 - self.r**2) < eps def __repr__(self): return "(%s, %s, %s)" % (self.x, self.y, self.r) def count_regions(n, circles): if n == 1: return 2 if n == 2: return 3 + circles[0].intersects(circles[1]) if n == 3: c0, c1, c2 = circles if c0.not_intersects(c1): if c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.ex_touches(c2) or c2.not_intersects(c0): return 4 + c1.intersects(c2) elif c0.contains(c2) or c0.in_touches(c2): return 4 elif c0.contains(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 + c1.intersects(c2) elif c0.ex_touches(c2) or c0.not_intersects(c2): return 4 elif c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.in_touches(c1): if c0.in_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2) or c0.ex_touches(c2): return 4 elif c0.contains(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 7/6, depends on intersections c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.ex_touches(c2) or c2.in_touches(c1)) elif c0.ex_touches(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 elif c0.ex_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 8/7/6? c0_x_c1 = c0.get_intersections(c1) return 7 + all(not c2.is_on(p) for p in c0_x_c1) elif c1.ex_touches(c2): return 6 else: return 5 elif c0.intersects(c1): if c0.not_intersects(c2): return 5 + c1.intersects(c2) elif c0.contains(c2): # [?] c1.intersects(c2) -> ? return 5 + c1.intersects(c2) elif c0.in_touches(c2) or c0.ex_touches(c2): if c1.intersects(c2): c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.in_touches(c2) or c1.ex_touches(c2)) elif c0.intersects(c2): c0_x_c1 = c0.get_intersections(c1) if c1.intersects(c2): if all(not c2.is_on(p) for p in c0_x_c1): return 8 elif all(c2.is_on(p) for p in c0_x_c1): return 6 else: return 7 elif c1.in_touches(c2) or c1.ex_touches(c2) or c2.in_touches(c1): return 7 - any(c2.is_on(p) for p in c0_x_c1) else: # if c1.contains(c2) or c2.contains(c1) or c1.not_intersects(c2): return 6 return 4 return 0 def main(): n = int(input()) circles = [tuple(map(int, input().split())) for c in range(n)] circles.sort(key=lambda c: (-c[2], c[0], c[1])) circles = [Circle(*u) for u in circles] # print(n, circles) print(count_regions(n, circles)) if __name__ == '__main__': main() ```
output
1
45,135
23
90,271
Provide tags and a correct Python 3 solution for this coding contest problem. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image>
instruction
0
45,136
23
90,272
Tags: geometry, graphs Correct Solution: ``` from math import sqrt pt = lambda *a, **k: print(*a, **k, flush=True) rd = lambda: map(int, input().split()) n = int(input()) def f(x1, y1, r1, x2, y2, r2): a = (r1 + r2) ** 2 b = (r1 - r2) ** 2 d = (x1 - x2) ** 2 + (y1 - y2) ** 2 if d > a: return 1 elif d == a: return 4 elif d < b: return 3 elif d == b: return 5 else: return 2 def g(x1, y1, r1, x2, y2, r2): ds = (x1 - x2) ** 2 + (y1 - y2) ** 2 d = sqrt(ds) A = (r1 ** 2 - r2 ** 2 + ds) / (2 * d) h = sqrt(r1 ** 2 - A ** 2) x = x1 + A * (x2 - x1) / d y = y1 + A * (y2 - y1) / d x3 = x - h * (y2 - y1) / d y3 = y + h * (x2 - x1) / d x4 = x + h * (y2 - y1) / d y4 = y - h * (x2 - x1) / d return x3, y3, x4, y4 if n is 1: pt(2) if n is 2: x1, y1, r1 = rd() x2, y2, r2 = rd() a = f(x1, y1, r1, x2, y2, r2) pt(4 if a is 2 else 3) if n is 3: x1, y1, r1 = rd() x2, y2, r2 = rd() x3, y3, r3 = rd() a = f(x1, y1, r1, x2, y2, r2) b = f(x1, y1, r1, x3, y3, r3) c = f(x3, y3, r3, x2, y2, r2) t = [a, b, c] t.sort() a, b, c = t if a is 1 and b is 1 and c in [1, 3, 4, 5]: pt(4) if a is 1 and b is 1 and c is 2: pt(5) if a is 1 and b is 2 and c is 2: pt(6) if a is 1 and b is 2 and c in [3, 4, 5]: pt(5) if a is 1 and b in [3, 4, 5]: pt(4) if a is 2 and b is 2 and c is 2: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) r = 8 if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 if abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 pt(r) if a is 2 and b is 2 and c is 3: pt(6) if a is 2 and b is 2 and c in [4, 5]: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6 or abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: pt(6) else: pt(7) if a is 2 and b is 3: pt(5) if a is 2 and b in [4, 5]: pt(6) if a is 3 and b in [3, 4, 5]: pt(4) if a is 4 and b is 4 and c is 4: pt(5) if a is 4 and b is 4 and c is 5: pt(4) if a is 4 and b is 5 and c is 5: pt(5) if a is 5 and b is 5 and c is 5: pt(4) ```
output
1
45,136
23
90,273
Provide tags and a correct Python 3 solution for this coding contest problem. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image>
instruction
0
45,137
23
90,274
Tags: geometry, graphs Correct Solution: ``` from math import sqrt pt = lambda *a, **k: print(*a, **k, flush=True) rd = lambda: map(int, input().split()) n = int(input()) def f(x1, y1, r1, x2, y2, r2): a = (r1 + r2) ** 2 b = (r1 - r2) ** 2 d = (x1 - x2) ** 2 + (y1 - y2) ** 2 if d > a: return 1 elif d == a: return 4 elif d < b: return 3 elif d == b: return 5 else: return 2 def g(x1, y1, r1, x2, y2, r2): ds = (x1 - x2) ** 2 + (y1 - y2) ** 2 d = sqrt(ds) A = (r1 ** 2 - r2 ** 2 + ds) / (2 * d) h = sqrt(r1 ** 2 - A ** 2) x = x1 + A * (x2 - x1) / d y = y1 + A * (y2 - y1) / d x3 = x - h * (y2 - y1) / d y3 = y + h * (x2 - x1) / d x4 = x + h * (y2 - y1) / d y4 = y - h * (x2 - x1) / d return x3, y3, x4, y4 if n is 1: pt(2) if n is 2: x1, y1, r1 = rd() x2, y2, r2 = rd() a = f(x1, y1, r1, x2, y2, r2) pt(4 if a is 2 else 3) if n is 3: x1, y1, r1 = rd() x2, y2, r2 = rd() x3, y3, r3 = rd() a = f(x1, y1, r1, x2, y2, r2) b = f(x1, y1, r1, x3, y3, r3) c = f(x3, y3, r3, x2, y2, r2) t = [a, b, c] t.sort() a, b, c = t if a is 1 and b is 1 and c in [1, 3, 4, 5]: pt(4) if a is 1 and b is 1 and c is 2: pt(5) if a is 1 and b is 2 and c is 2: pt(6) if a is 1 and b is 2 and c in [3, 4, 5]: pt(5) if a is 1 and b in [3, 4, 5]: pt(4) if a is 2 and b is 2 and c is 2: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) r = 8 if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 if abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: r -= 1 pt(r) if a is 2 and b is 2 and c is 3: pt(6) if a is 2 and b is 2 and c in [4, 5]: x4, y4, x5, y5 = g(x1, y1, r1, x2, y2, r2) if abs((x4 - x3) ** 2 + (y4 - y3) ** 2 - r3 ** 2) < 1e-6 or abs((x5 - x3) ** 2 + (y5 - y3) ** 2 - r3 ** 2) < 1e-6: pt(6) else: pt(7) if a is 2 and b is 3: pt(5) if a is 2 and b in [4, 5]: pt(6) if a is 3 and b in [3, 4, 5]: pt(4) if a is 4 and b is 4 and c is 4: pt(5) if a is 4 and b is 4 and c is 5: pt(4) if a is 4 and b is 5 and c is 5: pt(5) if a is 5 and b is 5 and c is 5: pt(4) # Made By Mostafa_Khaled ```
output
1
45,137
23
90,275
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image> Submitted Solution: ``` from decimal import * getcontext().prec = 40 eps = Decimal('1e-10') class Circle: def __init__(self, x, y, r): self.x = x self.y = y self.r = r def contains(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd < (self.r - c.r)**2 and self.r > c.r def in_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r - c.r)**2 and self.r > c.r def ex_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r + c.r)**2 def intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return (self.r - c.r)**2 < dd < (self.r + c.r)**2 def not_intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd > (self.r + c.r)**2 def get_intersections(self, c): x1, y1, r1, x2, y2, r2 = map(Decimal, [self.x, self.y, self.r, c.x, c.y, c.r]) RR = (x1-x2)**2 + (y1-y2)**2 rx1 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry1 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) rx2 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry2 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) return {(rx1, ry1), (rx2, ry2)} def is_on(self, p): return abs((self.x - p[0])**2 + (self.y - p[1])**2 - self.r**2) < eps def __repr__(self): return "(%s, %s, %s)" % (self.x, self.y, self.r) def count_regions(n, circles): if n == 1: return 2 if n == 2: return 3 + circles[0].intersects(circles[1]) if n == 3: c0, c1, c2 = circles if c0.not_intersects(c1): if c0.intersects(c2): return 5 elif c0.ex_touches(c2) or c2.not_intersects(c0): return 4 + c1.intersects(c2) elif c0.contains(c2) or c0.in_touches(c2): return 4 elif c0.contains(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 + c1.intersects(c2) elif c0.ex_touches(c2) or c0.not_intersects(c2): return 4 elif c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.in_touches(c1): if c0.in_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2) or c0.ex_touches(c2): return 4 elif c0.contains(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 7/6, depends on intersections c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.ex_touches(c2) or c2.in_touches(c1)) elif c0.ex_touches(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 elif c0.ex_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if not c1.intersects(c2): return 5 # intersects: 6/7/8 elif c0.intersects(c1): if c0.not_intersects(c2): return 5 + c1.intersects(c2) elif c0.contains(c2): # [?] c1.intersects(c2) -> ? return 5 + c1.intersects(c2) elif c0.in_touches(c2): if c1.intersects(c2): # c0_x_c2 = c0.get_intersections(c2) # return 6 + all(not c1.is_on(p) for p in c0_x_c2) return 6 else: return 5 + (c1.in_touches(c2) or c1.ex_touches(c2)) elif c0.intersects(c2): c0_x_c1 = c0.get_intersections(c1) if c1.intersects(c2): if all(not c2.is_on(p) for p in c0_x_c1): return 8 elif all(c2.is_on(p) for p in c0_x_c1): return 6 else: return 7 elif c1.in_touches(c2) or c1.ex_touches(c2) or c2.in_touches(c1): return 7 - any(c2.is_on(p) for p in c0_x_c1) elif c1.contains(c2) or c2.contains(c1): return 6 return 4 return 0 def main(): n = int(input()) circles = [tuple(map(int, input().split())) for c in range(n)] circles.sort(key=lambda c: (-c[2], c[0], c[1])) circles = [Circle(*u) for u in circles] # print(n, circles) print(count_regions(n, circles)) if __name__ == '__main__': main() ```
instruction
0
45,138
23
90,276
No
output
1
45,138
23
90,277
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image> Submitted Solution: ``` from decimal import * getcontext().prec = 40 eps = Decimal('1e-10') class Circle: def __init__(self, x, y, r): self.x = x self.y = y self.r = r def contains(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd < (self.r - c.r)**2 and self.r > c.r def in_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r - c.r)**2 and self.r > c.r def ex_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r + c.r)**2 def intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return (self.r - c.r)**2 < dd < (self.r + c.r)**2 def not_intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd > (self.r + c.r)**2 def get_intersections(self, c): x1, y1, r1, x2, y2, r2 = map(Decimal, [self.x, self.y, self.r, c.x, c.y, c.r]) RR = (x1-x2)**2 + (y1-y2)**2 rx1 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry1 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) rx2 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry2 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) return {(rx1, ry1), (rx2, ry2)} def is_on(self, p): return abs((self.x - p[0])**2 + (self.y - p[1])**2 - self.r**2) < eps def __repr__(self): return "(%s, %s, %s)" % (self.x, self.y, self.r) def count_regions(n, circles): if n == 1: return 2 if n == 2: return 3 + circles[0].intersects(circles[1]) if n == 3: c0, c1, c2 = circles if c0.not_intersects(c1): if c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.ex_touches(c2) or c2.not_intersects(c0): return 4 + c1.intersects(c2) elif c0.contains(c2) or c0.in_touches(c2): return 4 elif c0.contains(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 + c1.intersects(c2) elif c0.ex_touches(c2) or c0.not_intersects(c2): return 4 elif c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.in_touches(c1): if c0.in_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2) or c0.ex_touches(c2): return 4 elif c0.contains(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 7/6, depends on intersections c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.ex_touches(c2) or c2.in_touches(c1)) elif c0.ex_touches(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 elif c0.ex_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 8/7/6? c0_x_c1 = c0.get_intersections(c1) return 7 + all(not c2.is_on(p) for p in c0_x_c1) else: return 5 elif c0.intersects(c1): if c0.not_intersects(c2): return 5 + c1.intersects(c2) elif c0.contains(c2): # [?] c1.intersects(c2) -> ? return 5 + c1.intersects(c2) elif c0.in_touches(c2) or c0.ex_touches(c2): if c1.intersects(c2): c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.in_touches(c2) or c1.ex_touches(c2)) elif c0.intersects(c2): c0_x_c1 = c0.get_intersections(c1) if c1.intersects(c2): if all(not c2.is_on(p) for p in c0_x_c1): return 8 elif all(c2.is_on(p) for p in c0_x_c1): return 6 else: return 7 elif c1.in_touches(c2) or c1.ex_touches(c2) or c2.in_touches(c1): return 7 - any(c2.is_on(p) for p in c0_x_c1) else: # if c1.contains(c2) or c2.contains(c1) or c1.not_intersects(c2): return 6 return 4 return 0 def main(): n = int(input()) circles = [tuple(map(int, input().split())) for c in range(n)] circles.sort(key=lambda c: (-c[2], c[0], c[1])) circles = [Circle(*u) for u in circles] # print(n, circles) print(count_regions(n, circles)) if __name__ == '__main__': main() ```
instruction
0
45,139
23
90,278
No
output
1
45,139
23
90,279
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely. Input The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles. The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time. Output Print a single integer — the number of regions on the plane. Examples Input 3 0 0 1 2 0 1 4 0 1 Output 4 Input 3 0 0 2 3 0 2 6 0 2 Output 6 Input 3 0 0 2 2 0 2 1 1 2 Output 8 Note For the first example, <image> For the second example, <image> For the third example, <image> Submitted Solution: ``` from decimal import * getcontext().prec = 40 eps = Decimal('1e-10') class Circle: def __init__(self, x, y, r): self.x = x self.y = y self.r = r def contains(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd < (self.r - c.r)**2 and self.r > c.r def in_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r - c.r)**2 and self.r > c.r def ex_touches(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd == (self.r + c.r)**2 def intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return (self.r - c.r)**2 < dd < (self.r + c.r)**2 def not_intersects(self, c): dd = (self.x - c.x)**2 + (self.y - c.y)**2 # dd = d*d return dd > (self.r + c.r)**2 def get_intersections(self, c): x1, y1, r1, x2, y2, r2 = map(Decimal, [self.x, self.y, self.r, c.x, c.y, c.r]) RR = (x1-x2)**2 + (y1-y2)**2 rx1 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry1 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) + (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) rx2 = (x1+x2)/2 + (r1**2-r2**2)/(2*RR)*(x2-x1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (y2-y1) ry2 = (y1+y2)/2 + (r1**2-r2**2)/(2*RR)*(y2-y1) - (2*(r1**2+r2**2)/RR-(r1**2-r2**2)**2/(RR**2)-1).sqrt()/2 * (x1-x2) return {(rx1, ry1), (rx2, ry2)} def is_on(self, p): return abs((self.x - p[0])**2 + (self.y - p[1])**2 - self.r**2) < eps def __repr__(self): return "(%s, %s, %s)" % (self.x, self.y, self.r) def count_regions(n, circles): if n == 1: return 2 if n == 2: return 3 + circles[0].intersects(circles[1]) if n == 3: c0, c1, c2 = circles if c0.not_intersects(c1): if c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.ex_touches(c2) or c2.not_intersects(c0): return 4 + c1.intersects(c2) elif c0.contains(c2) or c0.in_touches(c2): return 4 elif c0.contains(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 + c1.intersects(c2) elif c0.ex_touches(c2) or c0.not_intersects(c2): return 4 elif c0.intersects(c2): return 5 + c1.intersects(c2) elif c0.in_touches(c1): if c0.in_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2) or c0.ex_touches(c2): return 4 elif c0.contains(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if c1.intersects(c2): # intersects: 7/6, depends on intersections c0_x_c2 = c0.get_intersections(c2) return 6 + all(not c1.is_on(p) for p in c0_x_c2) else: return 5 + (c1.ex_touches(c2) or c2.in_touches(c1)) elif c0.ex_touches(c1): if c0.in_touches(c2) or c0.contains(c2): return 4 elif c0.ex_touches(c2): if c1.intersects(c2): return 6 elif c1.ex_touches(c2): return 5 else: return 4 elif c0.not_intersects(c2): return 4 + c1.intersects(c2) elif c0.intersects(c2): if not c1.intersects(c2): return 5 # intersects: 6/7/8 elif c0.intersects(c1): if c0.not_intersects(c2): return 5 + c1.intersects(c2) elif c0.contains(c2): # [?] c1.intersects(c2) -> ? return 5 + c1.intersects(c2) elif c0.in_touches(c2): if c1.intersects(c2): # c0_x_c2 = c0.get_intersections(c2) # return 6 + all(not c1.is_on(p) for p in c0_x_c2) return 6 else: return 5 + (c1.in_touches(c2) or c1.ex_touches(c2)) elif c0.intersects(c2): c0_x_c1 = c0.get_intersections(c1) if c1.intersects(c2): if all(not c2.is_on(p) for p in c0_x_c1): return 8 elif all(c2.is_on(p) for p in c0_x_c1): return 6 else: return 7 elif c1.in_touches(c2) or c1.ex_touches(c2) or c2.in_touches(c1): return 7 - any(c2.is_on(p) for p in c0_x_c1) else: # if c1.contains(c2) or c2.contains(c1) or c1.not_intersects(c2): return 6 return 4 return 0 def main(): n = int(input()) circles = [tuple(map(int, input().split())) for c in range(n)] circles.sort(key=lambda c: (-c[2], c[0], c[1])) circles = [Circle(*u) for u in circles] # print(n, circles) print(count_regions(n, circles)) if __name__ == '__main__': main() ```
instruction
0
45,140
23
90,280
No
output
1
45,140
23
90,281
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,282
23
90,564
"Correct Solution: ``` for _ in[0]*int(input()): a,b,c,d,e,f=map(float,input().split()) s,t,u=a*a+b*b,c*c+d*d,e*e+f*f x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d)) y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c)) print('%.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5)) ```
output
1
45,282
23
90,565
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,283
23
90,566
"Correct Solution: ``` p = int(input()) for i in range(p): x1, y1, x2, y2, x3, y3 = map(float, input().split(" ")) xa, ya, xb, yb = x2-x1, y2-y1, x3-x1, y3-y1 a = complex(xa, ya) b = complex(xb, yb) z0 = abs(a) ** 2 * b - abs(b) **2 * a z0 /= a.conjugate() * b - a * b.conjugate() z = z0 + complex(x1, y1) zx = "{0:.3f}".format(z.real) zy = "{0:.3f}".format(z.imag) r = "{0:.3f}".format(abs(z0)) print(zx, zy, r) ```
output
1
45,283
23
90,567
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,284
23
90,568
"Correct Solution: ``` #!/usr/bin/env python from math import * def g(x): y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000 if x < 0: y *= -1 return y def func(x): x1, y1, x2, y2, x3, y3 = x a = x1 - x2 b = y1 - y2 c = (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) / 2 d = x1 - x3 e = y1 - y3 f = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2 x = (e * c - b * f) / (a * e - b * d) y = (a * f - d * c) / (a * e - b * d) r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)) x = "{0:.3f}".format(g(x)) y = "{0:.3f}".format(g(y)) r = "{0:.3f}".format(g(r)) print(x + " " + y + " " + r) n = int(input()) a = [] for _ in range(n): a.append(list((map(float, input().split())))) for i in a: func(i) ```
output
1
45,284
23
90,569
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,285
23
90,570
"Correct Solution: ``` import math class Circle: def __init__(self,x,y,r): self.x = x self.y = y self.r = r def getCircle(x1, y1, x2, y2, x3, y3): d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) px = ((x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d py = ((x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2) b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2) c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2) s = (a + b + c) / 2 A = math.sqrt(s * (s - a) * (s - b) * (s - c)) r = a * b * c / (4 * A) return Circle(px,py,r) n = int(input()) for k in range(n): x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split()] circle = getCircle(x1, y1, x2, y2, x3, y3) print("%.3f %.3f %.3f" % (circle.x, circle.y, circle.r)) ```
output
1
45,285
23
90,571
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,286
23
90,572
"Correct Solution: ``` for _ in range(int(input())): a,d,b,e,c,f=map(float,input().split()) z=2*(b*f-c*e+c*d-a*f+a*e-b*d) x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5)) ```
output
1
45,286
23
90,573
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,287
23
90,574
"Correct Solution: ``` import math N = int(input()) for i in range(N): x1,y1,x2,y2,x3,y3 = map(float,input().split()) x =((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))) y =((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))) r = (x-x1)*(x-x1)+(y-y1)*(y-y1) print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,math.sqrt(r))) ```
output
1
45,287
23
90,575
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,288
23
90,576
"Correct Solution: ``` # -*- coding: utf-8 -*- import sys def length(a, b): return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5 def solve_sim_equ(a, b, c, d, e, f): ''' From Problem 0004. This function solves following equation. ax + by = c dx + ey = f ''' if a==0 and d==0: if b==0 and e==0: return 0., 0. if b != 0: return 0., c/b+0. else: return 0., f/e+0. elif b==0 and e==0: if a != 0: return 0., d/a+0. else: return 0., a/d+0. if b == 0: a, d = d, a b, e = e, b c, f = f, c g = e / b x = (g*c - f) / (g*a - d) y = (c - a*x) / b return x+0., y+0. def circumscribed_circle(x, y, z): def get_equ_coef(p, q): h_x = (p[0] + q[0]) / 2 h_y = (p[1] + q[1]) / 2 a = q[1] - p[1] b = p[0] - q[0] c = b * h_x - a * h_y return b, -a, c coef = get_equ_coef(x, y) + get_equ_coef(y, z) center = solve_sim_equ(*coef) r = length(center, x) return center, r def main(): N = int(input()) for i in range(N): vs = [float(v) for v in input().split()] a = (vs[0], vs[1]) b = (vs[2], vs[3]) c = (vs[4], vs[5]) center, r = circumscribed_circle(a, b, c) print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r)) if __name__ == '__main__': main() ```
output
1
45,288
23
90,577
Provide a correct Python 3 solution for this coding contest problem. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414
instruction
0
45,289
23
90,578
"Correct Solution: ``` from math import sqrt n = int(input()) for i in range(n): l = input() x1,y1,x2,y2,x3,y3=map(float,l.split(' ')) a_2 = (x1 - x2)**2 + (y1 - y2)**2 b_2 = (x2 - x3)**2 + (y2 - y3)**2 c_2 = (x3 - x1)**2 + (y3 - y1)**2 cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2) sin_a_2 = 1 - cos_a_2 r = round(sqrt(a_2/sin_a_2)/2,3) a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1) b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1) c = (y2 - y1)*(x3 - x1) d = (y3 - y1)*(x2 - x1) py = round((a-b)/(c-d)/2,3) a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1) b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1) c = (x2 - x1)*(y3 - y1) d = (x3 - x1)*(y2 - y1) px = round((a-b)/(c-d)/2,3) print('%.3f %.3f %.3f' %(px, py, r)) ```
output
1
45,289
23
90,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` class vertex(object): def __init__(self,a): self.x=a[0] self.y=a[1] class circle(object): def __init__(self,p,r): self.px=p.x self.py=p.y self.r=r class triangle(object): def __init__(self,a,b,c): self.a=a self.b=b self.c=c import math self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2) self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2) self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2) c=self.ab a=self.bc b=self.ca self.cosA=(b**2+c**2-a**2)/(2*b*c) self.cosB=(a**2+c**2-b**2)/(2*a*c) self.cosC=(b**2+a**2-c**2)/(2*b*a) self.sinA=math.sqrt(1-self.cosA**2) self.sinB=math.sqrt(1-self.cosB**2) self.sinC=math.sqrt(1-self.cosC**2) self.sin2A=2*self.sinA*self.cosA self.sin2B=2*self.sinB*self.cosB self.sin2C=2*self.sinC*self.cosC def area(self): import math s=(self.ab+self.bc+self.ca)/2 S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca)) return S def circumscribed(self): R=self.ab/(2*self.sinC) px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C) py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C) px=round(px,3) py=round(py,3) R=round(R,3) p=vertex((px,py)) return circle(p,R) n=eval(input()) p1=[] p2=[] p3=[] for i in range(n): a,b,c,d,e,f=list(map(float,input().split())) p1.append(vertex((a,b))) p2.append(vertex((c,d))) p3.append(vertex((e,f))) for i in range(n): Triangle=triangle(p1[i],p2[i],p3[i]) Circle=Triangle.circumscribed() print('%.3f %.3f %.3f'%(Circle.px,Circle.py,Circle.r)) ```
instruction
0
45,290
23
90,580
Yes
output
1
45,290
23
90,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` def circumcenter(vert1, vert2, vert3): # H/T: wikipedia.org/wiki/Circumscribed_circle # refer from https://gist.github.com/dhermes/9ce057da49df63345c33 Ax, Ay = vert1 Bx, By = vert2 Cx, Cy = vert3 D = 2 * (Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By)) norm_A = Ax**2 + Ay**2 norm_B = Bx**2 + By**2 norm_C = Cx**2 + Cy**2 Ux = norm_A * (By - Cy) + norm_B * (Cy - Ay) + norm_C * (Ay - By) Uy = -(norm_A * (Bx - Cx) + norm_B * (Cx - Ax) + norm_C * (Ax - Bx)) r = (Ax - Ux/D)*(Ax - Ux/D) + (Ay - Uy/D)* (Ay - Uy/D) r = float(r)**0.5 return [Ux/D, Uy/D, r] n = int(input()) for i in range(n): xs = list(map(float, input().split())) a = circumcenter(xs[0:2], xs[2:4], xs[4:6]) print(' '.join(map(lambda x:f'{x:0.03f}', a))) ```
instruction
0
45,291
23
90,582
Yes
output
1
45,291
23
90,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` # -*- coding: utf-8 -*- from math import sqrt # import numpy as np n = int(input()) for i in range(n): tmp = input().split(' ') a, b, c = [(float(tmp[i]), float(tmp[i+1])) for i in range(0, len(tmp), 2)] #A = np.array(((a[0], a[1], 1), # (b[0], b[1], 1), # (c[0], c[1], 1))) A_tmp1 = 1/(a[0]*b[1] + a[1]*c[0] + b[0]*c[1] - b[1]*c[0] - a[1]*b[0] - a[0]*c[1]) A_tmp2 = [[b[1]-c[1], -(a[1]-c[1]), a[1]-b[1]], [-(b[0]-c[0]), (a[0]-c[0]), -(a[0]-b[0])], [b[0]*c[1] - b[1]*c[0], -(a[0]*c[1] - a[1]*c[0]), a[0]*b[1] - a[1]*b[0]]] A = [list(map(lambda x: A_tmp1*x, A_tmp2[i])) for i in range(3)] #B = np.array((((-(a[0]**2 + a[1]**2))), # ((-(b[0]**2 + b[1]**2))), # ((-(c[0]**2 + c[1]**2))))) B = [[-(a[0]**2 + a[1]**2)], [-(b[0]**2 + b[1]**2)], [-(c[0]**2 + c[1]**2)]] tmp = [sum([A[i][j]*B[j][0] for j in range(3)]) for i in range(3)] # tmp = np.dot(np.linalg.inv(A), B) x = -tmp[0]/2 y = -tmp[1]/2 r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4) print('{:.3f} {:.3f} {:.3f}'.format(x, y, r)) ```
instruction
0
45,292
23
90,584
Yes
output
1
45,292
23
90,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` from math import cos, sin, sqrt, radians, degrees, acos, fabs if __name__ == '__main__': epsilon = 1e-9 # ??????????????\??? num = int(input()) for i in range(num): x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split(' ')] # ??????????????§????§???¢???cos???????±???????arccos??§?§??????????????????? a = sqrt((x1-x2)**2 + (y1-y2)**2) b = sqrt((x2-x3)**2 + (y2-y3)**2) c = sqrt((x1-x3)**2 + (y1-y3)**2) cosA = (b**2+c**2-a**2)/(2*b*c) # ???????§???????????????°?????£????????????????????\????????????????±????????????¨?????§????????? r = a / sin(acos(cosA)) / 2 """ ??????O?????§?¨????(x, y)??¨????????¨ (x-x1)**2 + (y-y1)**2 = (x-x2)**2 + (y-y2)**2 x**2 -2*x1*x + x1**2 + y**2 -2*y1*y + y1**2 = ... -2*x2*x, x2**2, -2*y2*y, y2**2 ?????¨????????¨ (-2*x1 + 2*x2)x + (-2y1 + 2*y2)y + (x1**2 + y1**2 - x2**2 - y2**2) = 0 x1, x3???????????????????§???? (-2*x1 + 2*x3)x + (-2y1 + 2*y3)y + (x1**2 + y1**2 - x3**2 - y3**2) = 0 """ A = -2*x1 + 2*x2 B = -2*y1 + 2*y2 C = -2*x1 + 2*x3 D = -2*y1 + 2*y3 E = x1**2 + y1**2 - x2**2 - y2**2 F = x1**2 + y1**2 - x3**2 - y3**2 x = 1/(A*D-B*C) * (D*E - B*F) y = 1/(A*D-B*C) * (-C*E + A*F) # ?¨????????????¨?????? -0.0 ???????????´???????????¶?????? 0.0 ????????? if fabs(x) < epsilon: x = 0.0 if fabs(y) < epsilon: y = 0.0 print('{0:.3f} {1:.3f} {2:.3f}'.format(-x, -y, r)) ```
instruction
0
45,293
23
90,586
Yes
output
1
45,293
23
90,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` import math n=int(input()) for i in range(n): x1,y1,x2,y2,x3,y3=[int(j) for j in input().split()] p_x=(x1+x2+x3)/3 p_y=(y1+y2+y3)/3 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2) print(round(p_x,3),round(p_y,3),round(r,3)) ```
instruction
0
45,294
23
90,588
No
output
1
45,294
23
90,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers. Output For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places. Example Input 1 0.0 0.0 2.0 0.0 2.0 2.0 Output 1.000 1.000 1.414 Submitted Solution: ``` def simultaneous_equasion(a, b, c, d, e, f): "??£???????¨????" det = a * d - b * c a11 = d / det a12 = - b / det a21 = - c / det a22 = a / det return a11 * e + a12 * f, a21 * e + a22 * f n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) # (x1, y1), (x2, y2)????????´???????????? # 2 * (x2 - x1) * x + 2 * (y2 - y1) * y = (y2 - y1) ^ 2 + (x2 - x1) ^ 2 a = 2 * (x2 - x1) b = 2 * (y2 - y1) c = 2 * (x3 - x1) d = 2 * (y3 - y1) e = (y2 - y1) ** 2 + (x2 - x1) ** 2 f = (y3 - y1) ** 2 + (x3 - x1) ** 2 px, py = simultaneous_equasion(a, b, c, d, e, f) print("%.3f %3f" % (round(px, 3), round(py, 3))) ```
instruction
0
45,295
23
90,590
No
output
1
45,295
23
90,591