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

32418번 - Heavy Light Decomposition 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB555100.000%

문제

In an array containing only positive integers, we say an integer is heavy if it appears more than once in the array, and light otherwise.

An array is good if the integers in the array alternate between light and heavy.

Given an array $a_1, \dots , a_N,ドル count the number of ways to partition it into some number of contiguous subarrays such that each subarray, when considered as an array on its own, is good. As the answer may be large, output it modulo 1ドル,円 000,円 003$.

입력

The first line of input contains a single integer, $N$.

The next line contains $N$ integers $a_1, \dots , a_N$ (1ドル ≤ a_i ≤ N$).

출력

The number of ways to partition the array into good contiguous subarrays, modulo 1ドル,円 000,円 003$.

제한

서브태스크

Subtask Score Bounds on $N$ Additional constraints
1 3 2ドル ≤ N ≤ 50,円 000$ For each $i,ドル $a_i ≤ 26$.
2 4 2ドル ≤ N ≤ 5,円 000$ No additional constraints.
3 5 2ドル ≤ N ≤ 500,円 000$ If $i$ is odd, then $a_i = 1$.
4 6 2ドル ≤ N ≤ 500,円 000$ Any number appears at most twice in the array.
5 7 2ドル ≤ N ≤ 500,円 000$ No additional constraints.

예제 입력 1

5
1 2 3 2 3

예제 출력 1

4

There are four valid partitions of $[1, 2, 3, 2, 3]$:

  • $[1], [2], [3], [2], [3]$
  • $[1], [2, 3, 2], [3]$
  • $[1], [2], [3, 2, 3]$
  • $[1, 2, 3, 2], [3]$

예제 입력 2

5
1 2 1 3 1

예제 출력 2

6

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCO 2024 5번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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