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

33190번 - Colorful Intervals 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB55191025.000%

문제

The Museum of Contemporary Art is holding a painting gallery focused on modern art, especially Monochromatic style paintings, which use only a single color. The gallery displays $n$ paintings arranged in a line.

The ICPC wants to bring students on an excursion to the gallery to spark their interest in art. However, the students are programmers, and everyone knows programmers only care about the colors of these modern paintings. They are also somewhat impatient. To keep their attention and to ensure they see every color without overwhelming them, the organizer decided to show them exactly two intervals of painting. This approach balances their short attention span and ensures all colors are represented. The task is to find two intervals of paintings such that each color appears at least once in at least one of the intervals, and the total number of paintings the students need to see is minimized.

입력

The input consists of a single line containing a non-negative integer $n$ (2ドル \le n \le 2000$), indicating the number of paintings. This is followed by $n$ lines, each containing a string representing the color of a painting. Each color is represented by a non-empty lowercase string with a length of less than 20ドル$. It is guaranteed that there are at least 2ドル$ and at most 50ドル$ different colors in the input.

출력

In the output, print the minimum number of paintings the ICPC students need to see, which is the sum of the lengths of the two intervals.

제한

예제 입력 1

5
blue
red
blue
black
red

예제 출력 1

3

예제 입력 2

8
peachfuzz
livingcoral
livingcoral
teal
teal
livingcoral
livingcoral
coral

예제 출력 2

5

힌트

출처

ICPC > Regionals > Asia West Continent > Iran > 2023 ICPC Asia Tehran Regional Contest M번

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

출처

대학교 대회

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

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