Skip to content

Conversation

@froglike6
Copy link
Collaborator

@froglike6 froglike6 commented Apr 30, 2025

πŸ”— 문제 링크

ν‰ν–‰μ‚¬λ³€ν˜•

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

30λΆ„

✨ μˆ˜λ„ μ½”λ“œ

μˆ˜λ„ μ½”λ“œ

ν•¨μˆ˜ main():
    - 점 A, B, C의 μ’Œν‘œλ₯Ό μž…λ ₯λ°›λŠ”λ‹€ (xA, yA, xB, yB, xC, yC)

    - μ„Έ 점이 일직선 μœ„μ— μžˆλŠ”μ§€ ν™•μΈν•˜κΈ° μœ„ν•΄ 벑터 외적 계산:
        cross = (xB - xA) * (yC - yA) - (yB - yA) * (xC - xA)
        λ§Œμ•½ cross == 0이라면:
            - ν‰ν–‰μ‚¬λ³€ν˜•μ„ λ§Œλ“€ 수 μ—†μœΌλ―€λ‘œ -1 좜λ ₯ ν›„ μ’…λ£Œ

    - μ„Έ 점 μ‚¬μ΄μ˜ 거리 계산:
        dAB = A와 B 사이 거리
        dBC = B와 C 사이 거리
        dCA = C와 A 사이 거리

    - κ°€λŠ₯ν•œ ν‰ν–‰μ‚¬λ³€ν˜•λ“€μ˜ λ‘˜λ ˆ 계산:
        s1 = AB + CA
        s2 = AB + BC
        s3 = BC + CA

    - λ‘˜λ ˆ μ΅œλŒ€μ™€ μ΅œμ†Œμ˜ 차이 계산 ν›„ 2λ°°:
        answer = 2 * (μ΅œλŒ“κ°’(s1, s2, s3) - μ΅œμ†Ÿκ°’(s1, s2, s3))

    - μ†Œμˆ˜μ  15μžλ¦¬κΉŒμ§€ μ •λ°€ν•˜κ²Œ 좜λ ₯

이 λ¬Έμ œλŠ” μ„Έ 점이 μ£Όμ–΄μ§ˆ λ•Œ λ§Œλ“€ 수 μžˆλŠ” ν‰ν–‰μ‚¬λ³€ν˜• 쀑, κ°€μž₯ κΈ΄ λ‘˜λ ˆμ™€ κ°€μž₯ 짧은 λ‘˜λ ˆμ˜ μ°¨λ₯Ό κ΅¬ν•˜λŠ” λ¬Έμ œμž…λ‹ˆλ‹€.
three_points
μœ„μ™€ 같이 μ„Έ 점이 μžˆμŠ΅λ‹ˆλ‹€. λ¨Όμ € μ„Έ 점이 ν•œ 직선 μœ„μ— 있으면 ν‰ν–‰μ‚¬λ³€ν˜•μœΌλ‘œ λͺ» λ§Œλ“€κΈ° λ•Œλ¬Έμ—, 이λ₯Ό λ¨Όμ € νŒλ³„ν•©λ‹ˆλ‹€.
vectors_at_A
$A$λ₯Ό μ›μ μœΌλ‘œ ν•˜λŠ” 벑터λ₯Ό λ§Œλ“€μ–΄μ„œ 내적을 ν•©λ‹ˆλ‹€.
collinear_vectors
내적 κ²°κ³Όκ°€ 0이면 ν•œ 직선 μœ„μ— μžˆλ‹€λŠ” 것을 μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€($sin \theta=0$μ΄λ―€λ‘œ). 이제 μ„Έ 점 μ‚¬μ΄μ˜ 거리λ₯Ό κ΅¬ν•©λ‹ˆλ‹€.
side_lengths
이 거리λ₯Ό μ΄μš©ν•΄μ„œ, λ§Œλ“€μ–΄μ§ˆ 수 μžˆλŠ” ν‰ν–‰μ‚¬λ³€ν˜• λ‘˜λ ˆ κ°’μ˜ λ°˜μ„ ꡬ할 수 μžˆμŠ΅λ‹ˆλ‹€.
all_parallelograms
μ„Έ 점의 거리 쀑 2κ°œμ”© 골라 λ”ν•˜λ©΄, ν‰ν–‰μ‚¬λ³€ν˜•μ˜ λ‘˜λ ˆμ˜ 반이 λ©λ‹ˆλ‹€. λ”°λΌμ„œ λͺ¨λ“  경우λ₯Ό κ΅¬ν•˜κ³ , μ΅œλŒ“κ°’μ—μ„œ μ΅œμ†Ÿκ°’μ„ λΊ€ ν›„, 2λ°°ν•˜μ—¬ 좜λ ₯ν•˜λ©΄ λ¬Έμ œκ°€ ν•΄κ²°λ©λ‹ˆλ‹€.

μ²˜μŒμ—λŠ” ν‰ν–‰μ‚¬λ³€ν˜•μ˜ λ‚˜λ¨Έμ§€ ν•œ 점을 직접 κ΅¬ν•˜κ³ μž ν–ˆλŠ”λ°, 그림을 κ·Έλ¦¬λ‹€λ³΄λ‹ˆ μ΄λŸ¬ν•œ 방법이 μƒκ°λ‚¬μŠ΅λ‹ˆλ‹€.

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

μ§κ°μ‚Όκ°ν˜•μ΄λ‚˜ λ²‘ν„°μ˜ 노름을 κ΅¬ν•˜λŠ” 파이썬 ν•¨μˆ˜
math.hypotμ΄λΌλŠ” ν•¨μˆ˜λ₯Ό μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. κΈ°μ‘΄μ—λŠ” 직접 식을 κ΅¬ν˜„ν–ˆλŠ”λ°, 이 ν•¨μˆ˜λ₯Ό μ“°λ©΄ 쑰금 더 κ°„λ‹¨ν•΄μ§€λ„€μš” γ…Žγ…Ž

Copy link
Contributor

@dohyeondol1 dohyeondol1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 같은 λ°©μ‹μœΌλ‘œ ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€..
μ΅œκ·Όμ— κ³΅ν•™μˆ˜ν•™μ„ ν•˜κ³  μžˆμ–΄μ„œ κ·Έλ‚˜λ§ˆ ν’€ 수 μžˆλŠ” λ¬Έμ œμ˜€λ„€μš”.

μ—¬κΈ°μ„œ μ½”λ“œλ₯Ό 더 κ°œμ„ ν•  수 μžˆλ‚˜ κ³ λ―Όν•΄λ΄€λŠ”λ° 아직은 λ§ˆλ•…νžˆ λ– μ˜€λ₯΄λŠ” κ°œμ„ μ μ΄ 보이지 μ•Šλ„€μš”

λ§ˆμ§€λ§‰μ— 정닡을 μ €λŠ” μ„Έ ν‰ν–‰μ‚¬λ³€ν˜•μ˜ λ‘˜λ ˆλ₯Ό μ •λ ¬ν•΄μ„œ κ΅¬ν–ˆλŠ”λ°
이 λΆ€λΆ„μ—μ„œλŠ” μ•½κ°„μ˜ 차이가 μžˆλ„€μš” γ…Žγ…Ž

C++μ—μ„œλŠ” μ†Œμˆ˜μ  고정을 ν•΄μ€˜μ•Ό ACκ°€ λœ¨λ”λΌκ΅¬μš”

C++
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    double x_A, y_A, x_B, y_B, x_C, y_C;
    double length_AB, length_AC, length_BC;
    double square[3] = { 0 };

    cin >> x_A >> y_A >> x_B >> y_B >> x_C >> y_C;

    double cross = (x_B - x_A) * (y_C - y_B) - (y_B - y_A) * (x_C - x_B);
    if(cross == 0) {
        cout << "-1.0";
        return 0;
    }

    length_AB = sqrt((x_A - x_B) * (x_A - x_B) + (y_A - y_B) * (y_A - y_B));
    length_AC = sqrt((x_A - x_C) * (x_A - x_C) + (y_A - y_C) * (y_A - y_C));
    length_BC = sqrt((x_B - x_C) * (x_B - x_C) + (y_B - y_C) * (y_B - y_C));

    square[0] = (length_AB + length_AC) * 2;
    square[1] = (length_AB + length_BC) * 2;
    square[2] = (length_AC + length_BC) * 2;

    sort(square, square + 3);

    cout << fixed;
    cout.precision(16);
    cout << square[2] - square[0];

    return 0;
}

@froglike6 froglike6 changed the base branch from 8-froglike6 to main May 5, 2025 07:03
Copy link
Collaborator

@caucsejunseo caucsejunseo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μˆ˜ν•™ λ¬ΈμžλŠ” λ³Ό λ•Œλ§ˆλ‹€ μƒˆλ‘­λ„€μš”!
μ„Έ 점이 일직선이 되면 μ•ˆλœλ‹€λŠ” λ‹Ήμ—°ν•œ 것도 μ™œ λ°”λ‘œλ°”λ‘œ 생각이 μ•ˆλ‚˜λŠ”μ§€ 였래 κ³ λ―Όν–ˆλ„€μš”
μ²˜μŒμ— Dμ£„ν‘œ μ•ˆκ΅¬ν•˜κ³  κ·Έλƒ₯ AB, AC, BC μ„ λΆ„ 길이만 κ΅¬ν•΄μ„œ ν’€ 수 μžˆμ„μ€„ μ•Œκ³  ν’€λ‹€κ°€ 많이 ν‹€λ ΈμŠ΅λ‹ˆλ‹€...

C
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

double distance(double x1, double y1, double x2, double y2) {
    return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

int main() {
    double x1, y1, x2, y2, x3, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);

   
    if ((x2 - x1)*(y3 - y1) == (x3 - x1)*(y2 - y1)) {
        printf("-1.0\n");
        return 0;
    }

    double d1 = distance(x1, y1, x2, y2) + distance(x3, y3, x2 - x1 + x3, y2 - y1 + y3); // A-B κΈ°μ€€
    double d2 = distance(x1, y1, x3, y3) + distance(x2, y2, x3 - x1 + x2, y3 - y1 + y2); // A-C κΈ°μ€€
    double d3 = distance(x2, y2, x3, y3) + distance(x1, y1, x3 - x2 + x1, y3 - y2 + y1); // B-C κΈ°μ€€

    d1 *= 2;
    d2 *= 2;
    d3 *= 2;

    double max = d1;
    if (d2 > max) max = d2;
    if (d3 > max) max = d3;

    double min = d1;
    if (d2 < min) min = d2;
    if (d3 < min) min = d3;

    printf("%.10lf\n", max - min);
    return 0;
}

Copy link
Collaborator

@hadongun hadongun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ²˜μŒμ— λ„ν˜„λ‹˜μ΄ μ“°μ‹  방법인 μ„Έ 점의 거리 쀑 2κ°œμ”© 골라 λ”ν•˜λŠ” 방식을 λ– μ˜¬λ ΈμœΌλ‚˜ ꡬ체화 ν•˜λŠ” κ³Όμ •μ—μ„œ μ‹€μˆ˜κ°€ μžˆμ–΄μ„œ 잘λͺ»λœ 방법인 쀄 μ•Œμ•˜λ„€μš”.. 이후 D점의 μ’Œν‘œλ₯Ό κ΅¬ν•˜λ € ν–ˆμœΌλ‚˜.. μ‹€νŒ¨ν•˜μ˜€λ„€μš₯.. 직접 κ·Έλ¦¬μ‹œλ©΄μ„œ 아이디어λ₯Ό μƒκ°ν•˜λŠ” 방식은 쒋은 것 κ°™μ•„μš”..!
κ²°κ΅­ λ„ν˜„λ‹˜κ³Ό λΉ„μŠ·ν•œ λ°©λ²•μœΌλ‘œ ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

π썬

import sys
import math
x_a, y_a, x_b, y_b, x_c, y_c = map(int, input().split())

if (y_b- y_a) * (x_c - x_b) == (y_c - y_b) * (x_b - x_a):
    print(-1)
    sys.exit()

ab_line = math.sqrt((x_a - x_b)*(x_a - x_b) + (y_a - y_b)*(y_a - y_b))
ac_line = math.sqrt((x_a - x_c)*(x_a - x_c) + (y_a - y_c)*(y_a - y_c))
bc_line = math.sqrt((x_c - x_b)*(x_c - x_b) + (y_c - y_b)*(y_c - y_b))

p1 = 2 * (ab_line + ac_line)
p2 = 2 * (ab_line + bc_line)
p3 = 2 * (ac_line + bc_line)

line_list = [p1, p2, p3]
line_list.sort()
print(f"{line_list[2]-line_list[0]:.10f}")

@froglike6 froglike6 merged commit 1af30f0 into main May 8, 2025
1 check passed
@froglike6 froglike6 deleted the 9-froglike6 branch May 13, 2025 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants