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. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,754
23
201,508
Tags: geometry, implementation Correct Solution: ``` n = int(input()) stars = [] for i in range(n): x, y = list(map(int, input().split())) stars.append((x, y)) x1, y1 = stars[0] ind1 = 0 x2, y2 = stars[1] ind2 = 1 x3, y3 = 0, 0 ind3 = 0 for i in range(2, n): x0, y0 = stars[i] if (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0) != 0: x3, y3 = x0, y0 ind3 = i break for i in range(2, n): x0, y0 = stars[i] if i == ind1 or i == ind2 or i == ind3: continue d1 = (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0) d2 = (x2 - x0) * (y3 - y2) - (x3 - x2) * (y2 - y0) d3 = (x3 - x0) * (y1 - y3) - (x1 - x3) * (y3 - y0) if (d1 >= 0 and d2 >= 0 and d3 >= 0) or (d1 <= 0 and d2 <= 0 and d3 <= 0): if d1 == 0 or d2 == 0: ind2 = i x2, y2 = x0, y0 elif d3 == 0 or (d1 > 0 and d2 > 0 and d3 > 0) or (d1 < 0 and d2 < 0 and d3 < 0): ind1 = i x1, y1 = x0, y0 print(ind1 + 1, ind2 + 1, ind3 + 1) ```
output
1
100,754
23
201,509
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,755
23
201,510
Tags: geometry, implementation Correct Solution: ``` n = int(input()) p = [] for i in range(n): p += [list(map(int,input().split()))+[i+1]] p = sorted(p) l = [[p[0]]] for i in range(1,n): if l[-1][0][0] < p[i][0]: l += [[p[i]]] else: l[-1] += [p[i]] m = len(l) for i in range(m): if len(l[i]) > 1: r = 1 if i == 0 else -1 print(l[i][0][2],l[i][1][2],l[i+r][0][2]) break else: u, v = l[0][0], l[1][0] n = [v[0]-u[0],v[1]-u[1]] a, b = -n[1], n[0] c = - a * u[0] - b * u[1] for i in range(2,m): z = l[i][0] if a * z[0] + b * z[1] + c != 0: print(u[2],v[2],z[2]) break else: u = v v = z ```
output
1
100,755
23
201,511
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,756
23
201,512
Tags: geometry, implementation Correct Solution: ``` #!/usr/bin/env python3 from collections import namedtuple from itertools import islice Point = namedtuple("Point", "x y") try: while True: n = int(input()) points = [Point(*map(int, input().split())) for i in range(n)] min_d = 1e20 i1 = i2 = 0 p0 = points[0] p1 = p2 = None for i, p in enumerate(islice(points, 1, None), 1): d = (p.x - p0.x)**2 + (p.y - p0.y)**2 if d < min_d: min_d = d p1 = p i1 = i assert p1 is not None dx1 = p1.x - p0.x dy1 = p1.y - p0.y min_d = 1e20 for i, p in enumerate(islice(points, 1, None), 1): if p is p1: continue dx2 = p.x - p0.x dy2 = p.y - p0.y if dx1 == 0: ok = dx2 != 0 elif dy1 == 0: ok = dy2 != 0 else: ok = dy1 * dx2 != dy2 * dx1 if ok: d = dx2**2 + dy2**2 if d < min_d: min_d = d p2 = p i2 = i # assert p2 is not None while p2 is None: pass print(1, i1 + 1, i2 + 1) except EOFError: pass ```
output
1
100,756
23
201,513
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,757
23
201,514
Tags: geometry, implementation Correct Solution: ``` t = [(list(map(int, input().split())) + [i + 1]) for i in range(int(input()))] t.sort() x, y, i = t[0] u, v, j = t[1] for a, b, k in t[2:]: if (u - x) * (b - y) - (v - y) * (a - x): break print(i, j, k) # Made By Mostafa_Khaled ```
output
1
100,757
23
201,515
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,758
23
201,516
Tags: geometry, implementation Correct Solution: ``` import math def on_one_line(x1, y1, x2, y2, x3, y3): result = x1 * y2 - y1 * x2 + y1 * x3 - x1 * y3 + x2 * y3 - x3 * y2; if result == 0: return True else: return False n = int(input().strip()) node = [] for i in range(n): a, b = input().strip().split() node.append([int(a), int(b)]) mindis1 = 0 minidx1 = 0 for i in range(1, n): dis1 = math.sqrt(math.pow((node[i][0]-node[0][0]),2) + math.pow((node[i][1]-node[0][1]),2)) if i == 1: mindis1 = dis1 minidx1 = i elif dis1 < mindis1: mindis1 = dis1 minidx1 = i mindis2 = 10000000000000 minidx2 = 0 for i in range(1, n): if on_one_line(node[0][0], node[0][1], node[minidx1][0], node[minidx1][1], node[i][0], node[i][1]) == False: dis2 = math.sqrt(math.pow((node[i][0]-node[minidx1][0]),2) + math.pow((node[i][1]-node[minidx1][1]),2)) if dis2 < mindis2: mindis2 = dis2 minidx2 = i print("1 " + str(minidx1+1) + " " + str(minidx2+1)) ```
output
1
100,758
23
201,517
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,759
23
201,518
Tags: geometry, implementation Correct Solution: ``` n = int(input()) ans = [] arr = [0] * n for idx in range(n): x, y = input().split() arr[idx] = (int(x) + int(y), int(x), idx + 1, int(y)) arr.sort() ans.append(arr[0][2]) ans.append(arr[1][2]) if arr[0][0] == arr[1][0]: w = arr[0][0] idx = 2 while(True): if arr[idx][0] == w: idx += 1 else: ans.append(arr[idx][2]) break else: idx = 2 while(True): if (arr[1][3] - arr[0][3]) * (arr[idx][1] - arr[1][1]) == (arr[idx][3] - arr[1][3]) * (arr[1][1] - arr[0][1]): idx += 1 else: ans.append(arr[idx][2]) break print(' '.join(map(str, ans))) ```
output
1
100,759
23
201,519
Provide tags and a correct Python 3 solution for this coding contest problem. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border).
instruction
0
100,760
23
201,520
Tags: geometry, implementation Correct Solution: ``` import sys import itertools def s(p1,p2,p3): return (p1[0]-p3[0])*(p2[1]-p3[1])-(p2[0]-p3[0])*(p1[1]-p3[1]) e = 1e-22 def inTri(p, p1, p2, p3): l = [p1,p2,p3] for i in itertools.permutations(l): if abs(t(i[0],i[1])-t(i[0],p))<=e and min(i[0][0],i[1][0])<=p[0]<=max(i[0][0],i[1][0]) and min(i[0][1],i[1][1])<=p[1]<=max(i[0][1],i[1][1]): return True return (s(p,p1,p2)<=0)==(s(p,p2,p3)<=0) and (s(p,p2,p3)<=0)==(s(p,p3,p1)<=0) def t(p1, p2): if p2[0] == p1[0]: return 2e9 return (p2[1]-p1[1])/(p2[0]-p1[0]) n = int(input()) l = [] n1 = 0 n2 = 1 n3 = -1 for i in range(n): p = tuple(map(int,input().split())) l.append(p) for i in range(2,n): if t(l[n1],l[n2]) == t(l[n1],l[i]) and (l[n1][0]-l[n2][0])**2+(l[n1][1]-l[n2][1])**2 > (l[n1][0]-l[i][0])**2+(l[n1][1]-l[i][1])**2: n2 = i for i in range(n): if i==n1 or i==n2: continue if abs(t(l[i],l[n1])-t(l[i],l[n2]))<=e: continue if n3<0: n3=i continue if inTri(l[i], l[n1],l[n2],l[n3]): n3 = i continue print(n1+1,n2+1,n3+1) ```
output
1
100,760
23
201,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` def cross_pr(a_): x1, y1, x2, y2 = a_[:] return x1 * y2 - x2 * y1 def vector(a_): x1, y1, x2, y2 = a_[:] return [x1 - x2, y1 - y2] def dist(a_): x1, y1 = a_[:] return (x1 * x1 + y1 * y1) ** 0.5 n = int(input()) x = [[] for i in range(n)] for i in range(n): x[i] = [int(i) for i in input().split()] a = [[0] * 2 for i in range(n - 1)] for i in range(1, n): a[i - 1][0] = dist(vector(x[i] + x[0])) a[i - 1][1] = i a.sort() ans = [0] * 3 ans[0] = 0 ans[1] = a[0][1] now = 2 * 10 ** 21 + 1 v1 = vector(x[ans[0]] + x[ans[1]]) for i in range(n): v2 = vector(x[i] + x[ans[1]]) if abs(cross_pr(v1 + v2)) > 0: if abs(cross_pr(v1 + v2)) < now: now = abs(cross_pr(v1 + v2)) ans[2] = i for i in range(3): ans[i] += 1 print(*ans) ```
instruction
0
100,761
23
201,522
Yes
output
1
100,761
23
201,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` t = [(list(map(int, input().split())), i) for i in range(1, int(input()) + 1)] t.sort() (x, y), i = t[0] (u, v), j = t[1] for (a, b), k in t[2:]: if (u - x) * (b - y) - (v - y) * (a - x): break print(i, j, k) ```
instruction
0
100,762
23
201,524
Yes
output
1
100,762
23
201,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` n = int(input()) points = [] for i in range(n): points.append(tuple(int(x) for x in input().split())) p0 = points[0] dist = lambda p, q: (p[0]-q[0])**2 + (p[1]-q[1])**2 s_points = sorted(list(enumerate(points)), key = lambda p: dist(p[1], p0)) p1 = s_points[1][1] def incident(p, q, r): u = (p[0] - q[0], p[1] - q[1]) v = (p[0] - r[0], p[1] - r[1]) return u[0]*v[1] - u[1]*v[0] == 0 for i in range(2, n): if not incident(p0, p1, s_points[i][1]): print(1, s_points[1][0]+1, s_points[i][0]+1) break else: print('wtf, dude?') ```
instruction
0
100,763
23
201,526
Yes
output
1
100,763
23
201,527
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` t = [(list(map(int, input().split())) + [i + 1]) for i in range(int(input()))] t.sort() x, y, i = t[0] u, v, j = t[1] for a, b, k in t[2:]: if (u - x) * (b - y) - (v - y) * (a - x): break print(i, j, k) ```
instruction
0
100,764
23
201,528
Yes
output
1
100,764
23
201,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` def check(x1, y1, x2, y2, x, y): a = (x1 - x) ** 2 + (y - y1) ** 2 + (x2 - x) ** 2 + (y - y2) ** 2 b = (x1 - x2) ** 2 + (y2 - y1) ** 2 b -= a if b < 0: return False b /= 2 b **= 2 a = ((x1 - x) ** 2 + (y - y1) ** 2) * ((x2 - x) ** 2 + (y - y2) ** 2) if a == b: return True else: return False def sqr(s): answer = 0 for i in range(len(s)): answer += s[i][0] * s[(i + 1) % len(s)][1] - s[i][1] * s[(i + 1) % len(s)][0] answer /= 2 answer = abs(answer) return answer def main(): n = int(input()) s = [] for i in range(n): a, b = map(int, input().split()) s.append([a, b, i + 1]) s.sort() i = 0 print(s) while s[i][0] == s[0][0]: i += 1 if i > 2: print(1, 2, i + 1) else: while check(s[i][0], s[i][1], s[0][0], s[0][1], s[1][0], s[1][1]): i += 1 print(s[0][2], s[1][2], s[i][2]) main() ```
instruction
0
100,765
23
201,530
No
output
1
100,765
23
201,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` n=int(input()) points=[list(map(int,input().split())) for i in range(n)] from random import randint i=0 j=1 p1,p2 = points[i],points[j] def dis(p1,p2): return (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2 def Area(p1,p2,p3): return p1[0]*abs(p2[1]-p3[1])+p2[0]*abs(p3[1]-p1[1])+p3[0]*abs(p1[1]-p2[1]) for k in range(n): if k==i or k==j: continue elif dis(points[i],points[j])==(dis(points[i],points[k])+dis(points[k],points[j])): j=k K=0 area=int(1e18) for k in range(n): if k==i or k==j: continue else: a=Area(points[i],points[j],points[k]) if area>a>0: area=a K=k print(i+1,j+1,K+1) ```
instruction
0
100,766
23
201,532
No
output
1
100,766
23
201,533
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` import math n = int(input()) p = [ list(map(int, input().split())) for i in range(0,n)] def isTriangle(p1,p2,p3): area = p1[0] * (p2[1] - p3[1]) + p2[1] * (p3[1] - p1[1]) + p3[1] * (p1[1] - p2[1]) return area > 0 minLen = -1 ind = -1 for i in range(2, n): if isTriangle(p[0],p[1], p[i]): m = (p[0][1] - p[1][1] )/(p[0][0] - p[1][0]) c = p[0][1] - m * p[0][0] curLen = (m*p[0][0] + c + p[0][1]) / math.sqrt(m*m + 1) if minLen == -1 or curLen < minLen: minLen = curLen ind = i print(1,2,ind + 1) ```
instruction
0
100,767
23
201,534
No
output
1
100,767
23
201,535
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going to take a look at the night sky. He would like to find three distinct stars and form a triangle. The triangle must have positive area. In addition, all other stars must lie strictly outside of this triangle. He is having trouble finding the answer and would like your help. Your job is to find the indices of three stars that would form a triangle that satisfies all the conditions. It is guaranteed that there is no line such that all stars lie on that line. It can be proven that if the previous condition is satisfied, there exists a solution to this problem. Input The first line of the input contains a single integer n (3 ≤ n ≤ 100 000). Each of the next n lines contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109). It is guaranteed that no two stars lie at the same point, and there does not exist a line such that all stars lie on that line. Output Print three distinct integers on a single line — the indices of the three points that form a triangle that satisfies the conditions stated in the problem. If there are multiple possible answers, you may print any of them. Examples Input 3 0 1 1 0 1 1 Output 1 2 3 Input 5 0 0 0 2 2 0 2 2 1 1 Output 1 3 5 Note In the first sample, we can print the three indices in any order. In the second sample, we have the following picture. <image> Note that the triangle formed by starts 1, 4 and 3 doesn't satisfy the conditions stated in the problem, as point 5 is not strictly outside of this triangle (it lies on it's border). Submitted Solution: ``` n=int(input()) points=[list(map(int,input().split())) for i in range(n)] i,j=0,1 def dis(p1,p2): return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)**0.5 def Area(p1,p2,p3): return (p1[0]*abs(p2[1]-p3[1])+p2[0]*abs(p3[1]-p1[1])+p3[0]*abs(p1[1]-p2[1])) for k in range(n): if k==i or k==j: continue elif abs(dis(points[i],points[j])-(dis(points[i],points[k])+dis(points[k],points[j])))<=1e-10: j=k K=0 print(i,j) area=int(1e20) for k in range(n): if k==i or k==j: continue else: a=Area(points[i],points[j],points[k]) if area>a>0: area=a K=k print(i+1,j+1,K+1) ```
instruction
0
100,768
23
201,536
No
output
1
100,768
23
201,537
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,800
23
201,600
Tags: data structures, hashing Correct Solution: ``` def define_nearest_primes(n): primes=[11,17,19,23,29,53,97,193,389,769,1543,3079,6151,12289,24593,49157,98317,1572869] for i in range(0, len(primes)): if primes[i]>1.5*n: p=primes[i] break return p def sort_box(box): if box[0]>box[1]: if box[0]>box[2]: if box[1]>box[2]: box=[box[2],box[1],box[0]] else: box=[box[1],box[2],box[0]] else: box=[box[1],box[0],box[2]] else: if box[0]<box[2]: if box[1]<box[2]: box=[box[0],box[1],box[2]] else: box=[box[0],box[2],box[1]] else: box=[box[2],box[0],box[1]] return(box) def hash_func(box,i,hash_table,biggest_merged_rectangular,p): index=(50033*box[2]+box[1]) % p while (len(hash_table[index])>0 and (box[1]!=hash_table[index][0][2] or box[2]!=hash_table[index][0][3])): index=(index+1) % p #print(box,index) if len(hash_table[index])==2: if box[0]>hash_table[index][0][1]: if hash_table[index][0][1]<hash_table[index][1][1]: hash_table[index][0]=[i,box[0],box[1],box[2]] else: hash_table[index][1]=[i,box[0],box[1],box[2]] else: if box[0]>hash_table[index][1][1]: hash_table[index][1]=[i,box[0],box[1],box[2]] temp_box=[hash_table[index][0][2],hash_table[index][0][3],hash_table[index][0][1]+hash_table[index][1][1]] temp_box=sort_box(temp_box) if biggest_merged_rectangular[2]<temp_box[0]: biggest_merged_rectangular=[hash_table[index][0][0],hash_table[index][1][0],temp_box[0]] else: if len(hash_table[index])==1: hash_table[index].append([i,box[0],box[1],box[2]]) temp_box=[hash_table[index][0][2],hash_table[index][0][3],hash_table[index][0][1]+hash_table[index][1][1]] temp_box=sort_box(temp_box) if biggest_merged_rectangular[2]<temp_box[0]: biggest_merged_rectangular=[hash_table[index][0][0],hash_table[index][1][0],temp_box[0]] else: hash_table[index].append([i,box[0],box[1],box[2]]) return hash_table, biggest_merged_rectangular def print_result(biggest_rectangular,biggest_merged_rectangular): if biggest_rectangular[1]>biggest_merged_rectangular[2]: print('1'+'\n'+str(biggest_rectangular[0])) else: if (biggest_merged_rectangular[0]<biggest_merged_rectangular[1]): print('2'+'\n'+str(biggest_merged_rectangular[0])+' '+str(biggest_merged_rectangular[1])) else: print('2'+'\n'+str(biggest_merged_rectangular[1])+' '+str(biggest_merged_rectangular[0])) def main(): n=int(input()) #the number of boxes p=define_nearest_primes(n) hash_table=[[] for i in range(0,p)] biggest_rectangular=[0,0] #we will also search in online format for largest rectangular: [index,radius] biggest_merged_rectangular=[0,0,0] #and merged rectangular: [index1,index2,radius] for i in range(1,n+1): box=input().split(" ") box=[int(box[0]),int(box[1]),int(box[2])] #print(box) if box[1]==box[0] and box[0]==box[2]: if biggest_rectangular[1]<box[0]: biggest_rectangular[0]=i biggest_rectangular[1]=box[0] else: box=sort_box(box) #now sides of the box are sorted from smallest to largest #print(sort_box(box)) if biggest_rectangular[1]<box[0]: biggest_rectangular[0]=i biggest_rectangular[1]=box[0] hashing=hash_func(box,i,hash_table,biggest_merged_rectangular,p) #online hashing process hash_table=hashing[0] #include the box into hash table biggest_merged_rectangular=hashing[1] #update the merged rectangular #print(biggest_merged_rectangular) #print(biggest_rectangular) print_result(biggest_rectangular,biggest_merged_rectangular) #f=open("output.txt", "w") #f.write(chosen_boxes[0]+'\n') if __name__ == "__main__": main() ```
output
1
100,800
23
201,601
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,801
23
201,602
Tags: data structures, hashing Correct Solution: ``` n = int(input()) lst = [] for i in range(n): lst.append([i + 1] + sorted([int(x) for x in input().split(' ')])) d = {} for elem in lst: if (elem[3], elem[2]) in d: d[(elem[3], elem[2])].append((elem[0], elem[1])) else: d[(elem[3], elem[2])] = [(elem[0], elem[1])] m = 0 ans = [] # print(d) for pair in d: m1, m2 = 0, 0 i1, i2 = 0, 0 for i in range(0, len(d[pair])): if d[pair][i][1] > m2: m1 = m2 m2 = d[pair][i][1] i1 = i2 i2 = d[pair][i][0] elif d[pair][i][1] > m1: m1 = d[pair][i][1] i1 = d[pair][i][0] # print(pair) # print(d[pair]) if i1 > 0: a = min(pair[0], pair[1], m1 + m2) if a > m: m = a ans = [i1, i2] else: a = min(pair[0], pair[1], m2) if a > m: m = a ans = [i2] # print(a, m, ans) print(len(ans)) print(' '.join([str(x) for x in ans])) ```
output
1
100,801
23
201,603
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,802
23
201,604
Tags: data structures, hashing Correct Solution: ``` N = int(input()) maxr = 0 maxi = [-1] sides = {} for x in range(N): cords = [int(x) for x in input().split()] cords.sort() if (cords[1], cords[2]) in sides: sides[(cords[1], cords[2])][0].append(cords[0]) sides[(cords[1], cords[2])][1].append(x+1) else: sides[(cords[1], cords[2])] = [ [cords[0]], [x+1], cords[1] ] if cords[0] > maxr: maxr = cords[0] maxi = [x + 1] for key in sides: maxA = 0 maxB = 0 Ai = 0 Bi = 0 for i,val in enumerate(sides[key][0]): if maxA < val: maxA = val Ai = i for i,val in enumerate(sides[key][0]): if i != Ai and maxB < val: maxB = val Bi = i newr2 = min(maxB+maxA, sides[key][2]) if newr2 > maxr: maxr = newr2 maxi = [ sides[key][1][Ai], sides[key][1][Bi] ] if len(maxi) == 1: print(1) print(maxi[0]) else: print(2) print(maxi[0], maxi[1]) ```
output
1
100,802
23
201,605
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,803
23
201,606
Tags: data structures, hashing Correct Solution: ``` def add_side(side1, side2, side3, side_dict, num): if (side1, side2) not in side_dict: side_dict[(side1, side2)] = [(side3, num)] else: side_dict[(side1, side2)].append((side3, num)) if len(side_dict[(side1, side2)]) > 2: side_dict[(side1, side2)] = sorted(side_dict[(side1, side2)])[1:3] n = int(input()) ans_k = 1 k1 = -1 ans = 0 side_dict = dict() cubes = list() for i in range(n): sides = sorted([int(x) for x in input().split()]) cubes.append(sides) if sides[0] / 2 > ans: k1 = i + 1 ans = sides[0] / 2 add_side(sides[0], sides[1], sides[2], side_dict, i) if sides[0] == sides[1] and sides[1] == sides[2]: pass else: if sides[0] == sides[1]: add_side(sides[0], sides[2], sides[1], side_dict, i) elif sides[1] == sides[2]: add_side(sides[1], sides[2], sides[0], side_dict, i) else: add_side(sides[0], sides[2], sides[1], side_dict, i) add_side(sides[1], sides[2], sides[0], side_dict, i) for pair in side_dict: if len(side_dict[pair]) > 1: sides = sorted([pair[0], pair[1], side_dict[pair][0][0] + side_dict[pair][1][0]]) if sides[0] / 2 > ans: ans = sides[0] / 2 ans_k = 2 k1 = side_dict[pair][0][1] + 1 k2 = side_dict[pair][1][1] + 1 print(ans_k) if ans_k == 1: print(k1) else: print(k1, k2) ```
output
1
100,803
23
201,607
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,804
23
201,608
Tags: data structures, hashing Correct Solution: ``` def main(): d, m = {}, 0 for i in range(1, int(input()) + 1): a, b, c = sorted(map(int, input().split())) if (b, c) in d: x, y, z, t = d[b, c] if a > z: d[b, c] = (a, i, x, y) if a > x else (x, y, a, i) else: d[b, c] = (a, i, 0, 0) for (a, b), (x, y, z, t) in d.items(): if a > m < x + z: m, res = x + z if a > x + z else a, (y, t) print(("2\n%d %d" % res) if res[1] else ("1\n%d" % res[0])) if __name__ == '__main__': main() ```
output
1
100,804
23
201,609
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,805
23
201,610
Tags: data structures, hashing Correct Solution: ``` n = int(input()) ar = [] for i in range(n): kek = list(map(int, input().split())) kek.sort() ar.append(kek + [i + 1]) ans = 0 kek = [0, 0] for i in range(n): if min(ar[i][0], ar[i][1], ar[i][2]) > ans: ans = min(ar[i][0], ar[i][1], ar[i][2]) kek[0] = ar[i][3] ar.sort(key=lambda x: [x[0], x[1], x[2]]) for i in range(1, n): if ar[i][0] == ar[i - 1][0] and ar[i][1] == ar[i - 1][1]: if min((ar[i][2] + ar[i - 1][2]), ar[i][0], ar[i][1]) > ans: ans = min((ar[i][2] + ar[i - 1][2]), ar[i][0], ar[i][1]) kek = [ar[i][3], ar[i - 1][3]] ar.sort(key=lambda x: [x[1], x[2], x[0]]) for i in range(1, n): if ar[i][2] == ar[i - 1][2] and ar[i][1] == ar[i - 1][1]: if min((ar[i][0] + ar[i - 1][0]), ar[i][2], ar[i][1]) > ans: ans = min((ar[i][0] + ar[i - 1][0]), ar[i][2], ar[i][1]) kek = [ar[i][3], ar[i - 1][3]] ar.sort(key=lambda x: [x[2], x[0], x[1]]) for i in range(1, n): if ar[i][2] == ar[i - 1][2] and ar[i][0] == ar[i - 1][0]: if min((ar[i][1] + ar[i - 1][1]), ar[i][0], ar[i][2]) > ans: min((ar[i][1] + ar[i - 1][1]), ar[i][0], ar[i][2]) kek = [ar[i][3], ar[i - 1][3]] ar.sort(key=lambda x:x[3]) if kek[1] == 0: print(1) print(kek[0]) else: print(2) print(*kek) ```
output
1
100,805
23
201,611
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,806
23
201,612
Tags: data structures, hashing Correct Solution: ``` import random def get_size(N): sizes = [23, 71, 151, 571, 1021, 1571, 5795, 11311, 15451, 50821, 96557, 160001, 262419] size = 11 idx = 0 while size < 2*N: size = sizes[idx] idx += 1 return size class Hash(object): def __init__(self, size): self.size = size self.items = [[] for i in range(size)] self.p1 = random.randint(1, size - 1) self.p2 = random.randint(1, size - 1) def count_index(self, b, c): return (b*self.p1 + c*self.p2) % self.size def get_pair(self, item): a, b, c, num = item idx = self.count_index(b, c) arr = self.items[idx] cur = None for i, cur in enumerate(arr): if cur[1] == b and cur[2] == c: break cur = None if cur: if cur[0] >= a: return cur[-1], item[-1], cur[0] + a else: self.items[idx][i] = item return item[-1], cur[-1], cur[0] + a else: self.items[idx].append(item) return None N = int(input()) R_max = 0 best_one = None best_pair = None if_one = True size = get_size(N) hash = Hash(size) for i in range(N): box = input().split() box = sorted([int(side) for side in box]) + [i + 1] if box[0] > R_max: best_one = i + 1 R_max = box[0] if_one = True cur_pair = hash.get_pair(box) if cur_pair: R_paired = min(box[1:-1] + [cur_pair[-1]]) if R_paired > R_max: R_max = R_paired best_pair = cur_pair[:-1] if_one = False #file = open('output.txt', 'w') if if_one: #file.write(str(1) + '\n' + str(best_one) + '\n' + str(R_max)) print(1) print(best_one) else: #file.write(str(2) + '\n' + str(best_pair[0]) + ' ' + str(best_pair[1]) + '\n' + str(R_max)) print(2) print(str(best_pair[0]) + ' ' + str(best_pair[1])) ```
output
1
100,806
23
201,613
Provide tags and a correct Python 3 solution for this coding contest problem. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone.
instruction
0
100,807
23
201,614
Tags: data structures, hashing Correct Solution: ``` n = int(input()) sidesInfo = {} lengthsToIndex = {} for i in range(n): sides = [int(side) for side in input().split()] sides.sort() if sides[2] not in sidesInfo: sidesInfo[sides[2]] = {} if sides[1] not in sidesInfo[sides[2]]: sidesInfo[sides[2]][sides[1]] = [] #record stone info; sidesInfo[sides[2]][sides[1]].append(sides[0]) if f"{sides[0]}_{sides[1]}_{sides[2]}" not in lengthsToIndex: lengthsToIndex[f"{sides[0]}_{sides[1]}_{sides[2]}"] = [] lengthsToIndex[f"{sides[0]}_{sides[1]}_{sides[2]}"].append(i + 1) max_amount = 1 max_combination = "" max_radius = 0 for sideLen in sidesInfo: for sideWid in sidesInfo[sideLen]: heightChosen = [] if len(sidesInfo[sideLen][sideWid]) >= 2: sidesInfo[sideLen][sideWid].sort() heightChosen.append(sidesInfo[sideLen][sideWid][-2]) heightChosen.append(sidesInfo[sideLen][sideWid][-1]) else: heightChosen.append(sidesInfo[sideLen][sideWid][0]) radiusMax = min(sideLen, sideWid, sum(heightChosen)) if radiusMax > max_radius: max_radius = radiusMax max_amount = len(heightChosen) if max_amount == 2: pair = [] pair.append(lengthsToIndex[f"{heightChosen[0]}_{sideWid}_{sideLen}"][0]) if heightChosen[0] == heightChosen[1]: pair.append(lengthsToIndex[f"{heightChosen[1]}_{sideWid}_{sideLen}"][1]) else: pair.append(lengthsToIndex[f"{heightChosen[1]}_{sideWid}_{sideLen}"][0]) pair.sort() max_combination = ' '.join(str(i) for i in pair) else: max_combination = lengthsToIndex[f"{heightChosen[0]}_{sideWid}_{sideLen}"][0] print(max_amount) print(max_combination) ```
output
1
100,807
23
201,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` import math,sys,bisect,heapq from collections import defaultdict,Counter,deque from itertools import groupby,accumulate #sys.setrecursionlimit(200000000) input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__ ilele = lambda: map(int,input().split()) alele = lambda: list(map(int, input().split())) def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] #MOD = 1000000000 + 7 def Y(c): print(["NO","YES"][c]) def y(c): print(["no","yes"][c]) def Yy(c): print(["No","Yes"][c]) N = int(input()) G= defaultdict(list) for i in range(N): a,b,c = ilele() C = sorted([a,b,c]) a,b,c = C l = i+1 if a==b == c: G[(a,b)].append((c,l)) elif a==b: G[(a,b)].append((c,l)) G[(b,c)].append((a,l)) elif b == c: G[(b,c)].append((a,l)) G[(a,b)].append((c,l)) else: G[(a,b)].append((c,l)) G[(b,c)].append((a,l)) G[(a,c)].append((b,l)) #print(G) maxi= 0 choose1 = None;choose2 = None for i,j in G.items(): if len(j) == 1: m = min(i[0],i[1],j[0][0]) if m> maxi: maxi = m choose1 = j[0][1] choose2 = None else: r = heapq.nlargest(2,j) m = min(r[0][0] + r[1][0],i[0],i[1]) if m>maxi: maxi = m choose1 = r[0][1] choose2 = r[1][1] if choose2 == None: print(1) print(choose1) else: print(2) print(choose1,choose2) ```
instruction
0
100,808
23
201,616
Yes
output
1
100,808
23
201,617
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` from collections import defaultdict n = int(input()) ab, bc, ca = defaultdict(list), defaultdict(list), defaultdict(list) single, double = 0, 0 sidx, didx = None, None for i in range(1, n + 1): a, b, c = sorted(map(int, input().split())) ab[(a, b)].append((c, i)) bc[(b, c)].append((a, i)) ca[(c, a)].append((b, i)) m = min(a, b, c) if m > single: single = m sidx = i for d in [ab, bc, ca]: for (p, q), v in d.items(): if len(v) <= 1: continue *_, (x, xi), (y, yi) = sorted(v) m = min(p, q, x + y) if m > double: double = m didx = (xi, yi) if single >= double: print("1\n%d" % sidx) else: print("2\n%d %d" % didx) ```
instruction
0
100,809
23
201,618
Yes
output
1
100,809
23
201,619
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` n = int(input()) a = [] ans,u,v = 0,-1,-1 for i in range(n): t = [int(x) for x in input().split()] t.sort() if ans < t[0]: ans = t[0] u = v = i t.append(i) a.append(t) from operator import itemgetter a.sort(key=itemgetter(1,2,0),reverse=True) i = 0 while i+1 < n: if a[i][1:3]==a[i+1][1:3]: t = min(a[i][0]+a[i+1][0],a[i][1]) if ans < t: ans = t u = a[i][3] v = a[i+1][3] i += 1 while (i==0 or a[i][1:3]==a[i-1][1:3]) and i+1<len(a): i += 1 if u == v: print(1) print(u+1) else: print(2) print(u+1,v+1) ```
instruction
0
100,810
23
201,620
Yes
output
1
100,810
23
201,621
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` def define_nearest_primes(n): primes = [11, 17, 19, 23, 29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 1572869] for i in range(0, len(primes)): if primes[i] > 1.5 * n: return primes[i] return primes[-1] def hash_func(box, i, hash_table, biggest_merged_rectangular, p): index = (50033 * box[2] + box[1]) % p while len(hash_table[index]) > 0 and (box[1] != hash_table[index][0][2] or box[2] != hash_table[index][0][3]): index = (index + 1) % p # print(index) if len(hash_table[index]) == 2: if box[0] > hash_table[index][0][1]: if hash_table[index][0][1] < hash_table[index][1][1]: hash_table[index][0] = [i, box[0], box[1], box[2]] else: hash_table[index][1] = [i, box[0], box[1], box[2]] elif box[0] > hash_table[index][1][1]: hash_table[index][1] = [i, box[0], box[1], box[2]] temp_box = [hash_table[index][0][2], hash_table[index][0][3], hash_table[index][0][1] + hash_table[index][1][1]] temp_box = sorted(temp_box) if biggest_merged_rectangular[2] < temp_box[0]: biggest_merged_rectangular = [hash_table[index][0][0], hash_table[index][1][0], temp_box[0]] else: if len(hash_table[index]) == 1: hash_table[index].append([i, box[0], box[1], box[2]]) temp_box = [hash_table[index][0][2], hash_table[index][0][3], hash_table[index][0][1] + hash_table[index][1][1]] temp_box = sorted(temp_box) if biggest_merged_rectangular[2] < temp_box[0]: biggest_merged_rectangular = [hash_table[index][0][0], hash_table[index][1][0], temp_box[0]] else: if biggest_merged_rectangular[2] < box[0]: biggest_merged_rectangular = [i, None, box[0]] hash_table[index].append([i, box[0], box[1], box[2]]) return hash_table, biggest_merged_rectangular if __name__ == "__main__": n = int(input()) # the number of boxes p = define_nearest_primes(n) hash_table = [[] for _ in range(0, p)] biggest_merged_rectangular = [0, 0, 0] # [index1,index2,radius] for i in range(1, n + 1): box = list(map(int, input().split())) box = sorted(box) # print(box) hashing = hash_func(box, i, hash_table, biggest_merged_rectangular, p) # online hashing process hash_table, biggest_merged_rectangular = hashing if biggest_merged_rectangular[1] is None: print('1\n{}'.format(biggest_merged_rectangular[0])) else: inds = sorted(biggest_merged_rectangular[:2]) print('2\n{} {}'.format(inds[0], inds[1])) ```
instruction
0
100,811
23
201,622
Yes
output
1
100,811
23
201,623
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` hash_table = {} n = int(input()) max_diam = 0 ordinal_numbers = [0] for i in range(1, n+1): seq = sorted(list(map(int, input().split())), reverse=True) + [i] face = (seq[0], seq[1]) try: best = hash_table[face] except: best = None if best is not None: new_z = seq[2] + best[2] diam = min(seq[:2] + [new_z]) if diam > max_diam: ordinal_numbers = [best[3], i] max_diam = diam if best[2] < seq[2]: hash_table[face] = seq else: if seq[2] > max_diam: ordinal_numbers = [i] max_diam = seq[2] hash_table[face] = seq print(len(ordinal_numbers)) print(" ".join(map(str, ordinal_numbers)), end='') ```
instruction
0
100,812
23
201,624
No
output
1
100,812
23
201,625
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` # I took these from https://planetmath.org/goodhashtableprimes, these numbers # should reduce the number of collisions PRIMES = [23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653, 100663319, 201326611, 402653189, 805306457, 1610612741] class HashTable: """ This hash table will only work with integer pairs as keys. It will possibly be several times slower than the default Python implementation, since I will make no effort to replace lists by arrays, avoid long arithmetic in the hashing function, or otherwise optimize the performance. Conceptually though, this class is a real hash table without using any embedded associative arrays. To deal with collisions, I used chaining and prime table sizes. I expand the table when load factor is >0.75 and contract it when it is <0.25. """ def __init__(self, m=PRIMES[0]): self.size = 0 self.prime_index = 0 self.buckets = [[] for _ in range(m)] self.m = m def __getitem__(self, item): item_hash = self._hash(item) for key, value in self.buckets[item_hash]: if key[0] == item[0] and key[1] == item[1]: return value raise KeyError def __setitem__(self, item, _value): item_hash = self._hash(item) for i, (key, value) in enumerate(self.buckets[item_hash]): if key[0] == item[0] and key[1] == item[1]: self.buckets[item_hash][i][1] = _value return self.buckets[item_hash].append([item, _value]) self.size += 1 if self._load_factor() > 0.75: self._rehash(up=True) def __delitem__(self, item): item_hash = self._hash(item) for i, (key, value) in enumerate(self.buckets[item_hash]): if key[0] == item[0] and key[1] == item[1]: self.buckets[item_hash].pop(i) self.size -= 1 if self._load_factor() < 0.25 and self.m >= PRIMES[1]: self._rehash(up=False) break def __contains__(self, item): item_hash = self._hash(item) for i, (key, value) in enumerate(self.buckets[item_hash]): if key[0] == item[0] and key[1] == item[1]: return True return False def __len__(self): return self.size def _load_factor(self): return self.size / self.m def _hash(self, key): # trivial but working return (3 * key[0] + key[1]) % self.m def _rehash(self, up=True): old_buckets = self.buckets if up: # expansion to the next "good prime" size if self.prime_index < len(PRIMES) - 1: self.m = PRIMES[self.prime_index + 1] self.prime_index += 1 else: self.m = 2 * self.m + 1 else: # contraction to the previous "good prime" size if (self.m // 2 + 1 < PRIMES[-1]) and self.m > PRIMES[-1]: self.m = PRIMES[-1] self.prime_index = len(PRIMES) - 1 elif self.prime_index > 0: self.m = PRIMES[self.prime_index - 1] self.prime_index -= 1 self.buckets = [[] for _ in range(self.m)] self.size = 0 for bucket in old_buckets: for key, value in bucket: self[key] = value if __name__ == '__main__': boxes = dict() box_count = int(input()) max_ball_diameter = 0 max_ball_indices = [0, -1] for i in range(box_count): c, b, a = sorted(map(int, input().split())) if (a, b) in boxes: edges, indices = boxes[(a, b)] if c > edges[0]: edges = [c, edges[0]] indices = [i, indices[0]] elif c > edges[1]: edges = [edges[0], c] indices = [indices[0], i] diameter_candidate = min(a, b, edges[0] + edges[1]) if diameter_candidate > max_ball_diameter: max_ball_indices = indices max_ball_diameter = diameter_candidate else: boxes[(a, b)] = ([c, 0], [i, -1]) if c > max_ball_diameter: max_ball_diameter = c max_ball_indices = [i, -1] max_ball_indices = sorted(max_ball_indices) if max_ball_indices[0] == -1: print('1\n' + '{}\n'.format(max_ball_indices[1] + 1)) else: print('2\n' + '{} {}\n'.format(max_ball_indices[0] + 1, max_ball_indices[1] + 1)) ```
instruction
0
100,813
23
201,626
No
output
1
100,813
23
201,627
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` import random def get_size(N): sizes = [23, 71, 151, 571, 1021, 1571, 5795, 11311, 15451, 50821, 96557, 160001, 262419] size = 11 idx = 0 while size < 2*N: size = sizes[idx] idx += 1 return size class Hash(object): def __init__(self, size): self.size = size self.items = [[] for i in range(size)] self.p1 = random.randint(1, size - 1) self.p2 = random.randint(1, size - 1) def count_index(self, b, c): return (b*self.p1 + c*self.p2)//self.size def get_pair(self, item): a, b, c, num = item idx = self.count_index(b, c) arr = self.items[idx] print(item, ':', idx, arr) cur = None for i, cur in enumerate(arr): if cur[1] == b and cur[2] == c: break cur = None if cur: print('cur', cur, cur[0] + a) if cur[0] >= a: return cur[-1], item[-1], cur[0] + a else: self.items[idx][i] = item return item[-1], cur[-1], cur[0] + a else: self.items[idx].append(item) return None N = int(input()) R_max = 0 best_one = None best_pair = None if_one = True size = get_size(N) hash = Hash(size) for i in range(N): box = input().split() box = sorted([int(side) for side in box]) + [i + 1] if box[0] > R_max: best_one = i + 1 R_max = box[0] if_one = True cur_pair = hash.get_pair(box) if cur_pair: box[0] = cur_pair[-1] R_paired = min(box[:-1]) if R_paired > R_max: R_max = R_paired best_pair = cur_pair[:-1] if_one = False #file = open('output.txt', 'w') if if_one: #file.write(str(1) + '\n' + str(best_one) + '\n' + str(R_max)) print(1) print(best_one) else: #file.write(str(2) + '\n' + str(best_pair[0]) + ' ' + str(best_pair[1]) + '\n' + str(R_max)) print(2) print(str(best_pair[0]) + ' ' + str(best_pair[1])) ```
instruction
0
100,814
23
201,628
No
output
1
100,814
23
201,629
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are ai, bi and ci. He can take no more than two stones and present them to Kostya. If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way. Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar. Input The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones. Output In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arbitrary order. If there are several answers print any of them. Examples Input 6 5 5 5 3 2 4 1 4 1 2 1 3 3 2 4 3 3 4 Output 1 1 Input 7 10 7 8 5 10 3 4 2 6 5 5 5 10 2 8 4 2 1 7 7 7 Output 2 1 5 Note In the first example we can connect the pairs of stones: * 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. * 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5 * 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 * 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5 Or take only one stone: * 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5 * 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5 * 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5 * 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1 * 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5 It is most profitable to take only the first stone. Submitted Solution: ``` n = int(input()) a = [] ans,u,v = 0,-1,-1 for i in range(n): t = [int(x) for x in input().split()] t.sort() if ans < t[0]: ans = t[0] u = v = i t.append(i) a.append(t) b = [] for x in a: if x[1] >= ans: b.append(x) for x in b: for y in b: if x[3] != y[3]: if x[1:2] == y[1:2]: t = max(x[0]+y[0],x[1]) if ans < t: ans = t u = x[3] v = y[3] if u == v: print(1) print(u+1) else: print(2) print(u+1,v+1) ```
instruction
0
100,815
23
201,630
No
output
1
100,815
23
201,631
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,106
23
202,212
"Correct Solution: ``` a = sorted(map(int,input().split())) print("yes" if a[0] == a[3] and a[4] == a[7] and a[8] == a[11] else "no") ```
output
1
101,106
23
202,213
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,107
23
202,214
"Correct Solution: ``` #標準入力 l = list(map(int,input().split())) #リストを小さい順に並べる l.sort() #4辺を1人組とし、1組の辺が全て同じであれば"yes"でなければ"no"を出力する if l[0] == l[1] == l[2] == l[3] and l[4] == l[5] == l[6] == l[7] and l[8] == l[9] == l[10] == l[11]:print("yes") else:print("no") ```
output
1
101,107
23
202,215
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,108
23
202,216
"Correct Solution: ``` data = list(map(int, input().split())) data.sort() ans = "yes" for i in range(0, 12, 4) : if data[i] != data[i+1] or data[i] != data[i+2] or data[i] != data[i+3] : ans = "no" print(ans) ```
output
1
101,108
23
202,217
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,109
23
202,218
"Correct Solution: ``` lst = sorted(map(int, input().split())) if lst[0] == lst[3] and lst[4] == lst[7] and lst[8] == lst[11]: print("yes") else: print("no") ```
output
1
101,109
23
202,219
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,110
23
202,220
"Correct Solution: ``` e= sorted(list(map(int, input().split()))) print("yes" if len(set(e[:4]))==len(set(e[4:8]))==len(set(e[8:]))==1 else "no") ```
output
1
101,110
23
202,221
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,111
23
202,222
"Correct Solution: ``` a = [int(i) for i in input().split()] a.sort() if a[0] == a[1] and a[1] == a[2] and a[2] == a[3] and a[4] == a[5] and a[5] == a[6] and a[6] == a[7] and a[8] == a[9] and a[9] == a[10] and a[10] == a[11]: print("yes") else: print("no") ```
output
1
101,111
23
202,223
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,112
23
202,224
"Correct Solution: ``` e = sorted(map(int, input().split())) print("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no") ```
output
1
101,112
23
202,225
Provide a correct Python 3 solution for this coding contest problem. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes
instruction
0
101,113
23
202,226
"Correct Solution: ``` e = sorted(map(int, input().split())) print("yes" if e[0] == e[3] and e[4] == e[7] and e[8] == e[11] else "no") ```
output
1
101,113
23
202,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` e = list(map(int, input().split())) e.sort() frag = True for i in range(1, 4): if e[0] != e[i]: frag = False break for i in range(5, 8): if e[4] != e[i]: frag = False break for i in range(9, 12): if e[8] != e[i]: frag = False break print("yes" if frag else "no") ```
instruction
0
101,114
23
202,228
Yes
output
1
101,114
23
202,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` ls = list(map(int, input().split())) ls.sort() if ls[0]==ls[1]==ls[2]==ls[3] and ls[4]==ls[5]==ls[6]==ls[7] and ls[8]==ls[9]==ls[10]==ls[11]: print('yes') else: print('no') ```
instruction
0
101,115
23
202,230
Yes
output
1
101,115
23
202,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` l=list(input().split()) l.sort() if l[0]==l[1]==l[2]==l[3] and l[4]==l[5]==l[6]==l[7]and l[8]==l[9]==l[10]==l[11]: print('yes') else: print('no') ```
instruction
0
101,116
23
202,232
Yes
output
1
101,116
23
202,233
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` x = input().split() print('yes' if all([x.count(x[i]) % 4 == 0 for i in range(len(x))]) else 'no') ```
instruction
0
101,117
23
202,234
Yes
output
1
101,117
23
202,235
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` ls = list(map(int, input().split())) ls.sort() if ls[0]==ls[1]==ls[2]==ls[3] and ls[4==ls[5]==ls[6]==ls[7] and ls[8]==ls[9]==ls[10]==ls[11]: print('yes') else: print('no') ```
instruction
0
101,118
23
202,236
No
output
1
101,118
23
202,237
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` li = list(map(int,input().split())) so = sorted(li) a = so[0] b = so[4] c = so[8] res = False for n in so[:4]: res = a==n for n in so[4:8]: res = b==n for n in so[8:]: res = c==n print(res) ```
instruction
0
101,119
23
202,238
No
output
1
101,119
23
202,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` e = list(map(int, input().split())) print("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no") ```
instruction
0
101,120
23
202,240
No
output
1
101,120
23
202,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or broken. Given the lengths of the twelve bars, write a program to determine if you can create a rectangular parallelepiped with all of them as sides. Input The input is given in the following format. e1 e2 ... e12 The input consists of one line and is given the integer ei (1 ≤ ei ≤ 100) representing the length of each bar. Output If a rectangular parallelepiped can be created, "yes" is output, and if it cannot be created, "no" is output. However, since a cube is a kind of rectangular parallelepiped, "yes" is output even if it is a cube. Examples Input 1 1 3 4 8 9 7 3 4 5 5 5 Output no Input 1 1 2 2 3 1 2 3 3 3 1 2 Output yes Submitted Solution: ``` li = list(map(int,input().split())) so = sorted(li) a = so[0] b = so[4] c = so[8] res = False for n in so[:4]: res = res and a==n for n in so[4:8]: res = res and b==n for n in so[8:]: res = res and c==n print(res) ```
instruction
0
101,121
23
202,242
No
output
1
101,121
23
202,243
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, <image>. The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers. <image> If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one. Input The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m). Output Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2). Examples Input 9 9 5 5 2 1 Output 1 3 9 7 Input 100 100 52 50 46 56 Output 17 8 86 92
instruction
0
101,485
23
202,970
Tags: implementation, math Correct Solution: ``` import sys from fractions import gcd with sys.stdin as fin, sys.stdout as fout: n, m, x, y, a, b = map(int, next(fin).split()) d = gcd(a, b) a //= d b //= d k = min(n // a, m // b) w = k * a h = k * b x1 = x - (w + 1) // 2 y1 = y - (h + 1) // 2 x1 = min(x1, n - w) y1 = min(y1, m - h) x1 = max(x1, 0) y1 = max(y1, 0) print(x1, y1, x1 + w, y1 + h, file=fout) ```
output
1
101,485
23
202,971
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, <image>. The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers. <image> If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one. Input The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m). Output Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2). Examples Input 9 9 5 5 2 1 Output 1 3 9 7 Input 100 100 52 50 46 56 Output 17 8 86 92
instruction
0
101,486
23
202,972
Tags: implementation, math Correct Solution: ``` #!/usr/bin/python3 def gcd(a, b): while a: a, b = b % a, a return b n, m, x, y, a, b = tuple(map(int, input().strip().split())) g = gcd(a, b) a //= g b //= g k = min(n // a, m // b) w = k * a h = k * b ans = [x - w + w // 2, y - h + h // 2, x + w // 2, y + h // 2] if ans[0] < 0: ans[2] -= ans[0] ans[0] = 0; if ans[1] < 0: ans[3] -= ans[1] ans[1] = 0 if ans[2] > n: ans[0] -= ans[2] - n ans[2] = n if ans[3] > m: ans[1] -= ans[3] - m ans[3] = m print('%d %d %d %d' % tuple(ans)) ```
output
1
101,486
23
202,973
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m). Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, <image>. The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers. <image> If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one. Input The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m). Output Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2). Examples Input 9 9 5 5 2 1 Output 1 3 9 7 Input 100 100 52 50 46 56 Output 17 8 86 92
instruction
0
101,487
23
202,974
Tags: implementation, math Correct Solution: ``` import math n, m, x, y, a, b = map(int, input().split()) gcd = math.gcd(a, b) a //= gcd b //= gcd max_ratio = min(n // a, m // b) a *= max_ratio b *= max_ratio x1 = max(0, min(x - (a + 1) // 2, n - a)) y1 = max(0, min(y - (b + 1) // 2, m - b)) print(x1, y1, x1 + a, y1 + b) ```
output
1
101,487
23
202,975