Logo
(追記) (追記ここまで)

21929번 - Colorful Rectangle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 512 MB41181157.895%

문제

You are given a set of points on a plane. Each point is colored either red, blue, or green. A rectangle is called colorful if it contains one or more points of every color inside or on its edges. Your task is to find an axis-parallel colorful rectangle with the shortest perimeter. An axis-parallel line segment is considered as a degenerated rectangle and its perimeter is twice the length of the line segment.

입력

The input consists of a single test case of the following format.

n
x1 y1 c1
.
.
.
xn yn cn

The first line contains an integer n (3 ≤ n ≤ 105) representing the number of points on the plane. Each of the following n lines contains three integers xi, yi, and ci satisfying 0 ≤ xi ≤ 108, 0 ≤ yi ≤ 108, and 0 ≤ ci ≤ 2. Each line represents that there is a point of color ci (0: red, 1: blue, 2: green) at coordinates (xi, yi). It is guaranteed that there is at least one point of every color and no two points have the same coordinates.

출력

Output a single integer in a line which is the shortest perimeter of an axis-parallel colorful rectangle.

제한

예제 입력 1

4
0 2 0
1 0 0
1 3 1
2 4 2

예제 출력 1

8

예제 입력 2

4
0 0 0
0 1 1
0 2 2
1 2 0

예제 출력 2

4

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2020 Asia Yokohama Regional D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /