IT
Редактор
1
Нажмите "Выполнить", чтобы запустить код.
Введите данные:
НовостьИнформатика ЕГЭ - 11 класс 06.03.2026 10:52

Задание 27. ЕГЭ (ИНФ)

from math import dist as d
def get_centroid(c):
    return min(c, key=lambda p: sum(d(p, t) for t in c))
C_A = [[], []]
for line in open('27_A_апробация.txt'):
    x, y = map(float, line.replace(',', '.').split())
    if 3 <= x <= 9 and 5 <= y <= 11: C_A[0].append((x, y))
    elif 6 <= x <= 12 and 15 <= y <= 25: C_A[1].append((x, y))
S_A = sorted([(len(c), get_centroid(c), c) for c in C_A])
A1, _,_= S_A[0]
A2 = sum(d(item[1], (-1.0, 1.3)) for item in S_A)
print(A1, int(A2 * 10000))

C_B = [[], [], []]
for line in open('27_B_апробация.txt'):
    x, y = map(float, line.replace(',', '.').split())
    if 15 <= x <= 25 and 10 <= y <= 20: C_B[0].append((x, y))
    elif 25 <= x <= 30 and 10 <= y <= 20: C_B[1].append((x, y))
    elif 15 <= x <= 20 and 25 <= y <= 35: C_B[2].append((x, y))
S_B = sorted([(len(c), get_centroid(c), c) for c in C_B])
n_mid, center_mid, points_mid = S_B[1]
n_max, center_max, points_max = S_B[-1]
B1 = sum(1 for p in points_mid if 0 < d(p, center_mid) <= 1.6)
B2 = max(d(p, center_max) for p in points_max)
print(B1, int(B2 * 10000))
from math import dist as d

def F(c):
    m = min(c, key=lambda p: sum(d(p[:2], t[:2]) for t in c))
    return m[:2]

C_A = [[], []]
for i in open('27_A_28766.txt'):
    p = i.replace(',', '.').split()
    x, y = map(float, p[:2])
    char = p[2] if len(p) > 2 else '---'
    t = (x, y, char)

    if y < 9: C_A[0].append(t)
    else:     C_A[1].append(t)

S = [[F(c), c] for c in C_A]
s1, d_pts1 = S[0][0], S[0][1]
s2, d_pts2 = S[1][0], S[1][1]
print(s1, len(d_pts1))
print(s2, len(d_pts2))

Y1 = []
for t in C_A[0]:
    if len(t[2]) >= 3 and t[2][0] == 'Y' and t[2][-3:] == 'III':
        Y1.append(t[:2])

Y2 = []
for t in C_A[1]:
    if len(t[2]) >= 3 and t[2][0] == 'Y' and t[2][-3:] == 'III':
        Y2.append(t[:2])

print(S)
print(Y1, Y2)