포럼
문제 ICPC00313

E. Entirely Unsorted Sequences

설명

-3mm

-10mm

You have recently been promoted to lead scientist at NASA, the National Association for Sorting Algorithms. Congratulations! Your primary responsibility is testing the sorting algorithms that your team produces. Fortunately, NASA has a large budget this year, and you were able to buy some state of the art integers you can use to test the sorting algorithms.

As the lead scientist, you are well aware that algorithms are tested by their behaviour on worst case inputs. So, to test sorting algorithms, you need sequences that are as unsorted as possible.

Given a sequence of numbers \((a_1,\ldots,a_n)\) we say that an element \(a_k\) is sorted if for all indices \(j\) such that $j >
k\(, \)a_j \geq a_k\( and\ for\ all\ indices \)j\( such\ that \)j < k\(, \)a_j \leq a_k$. For example, in $$ (1, 3, 2, 3, 4, 6, 5, 5) $$ the sorted elements are the 1, the second occurrence of 3, and the 4. Note that a sequence is sorted if and only if all its elements are sorted. A sequence is called entirely unsorted if none of its elements are sorted.

Given a sequence of integers, what is the number of entirely unsorted sequences you can make by permuting its elements? Two sequences \((b_1, \dots, b_n)\) and \((c_1, \dots, c_n)\) are considered to be different if there is some index \(i \in \left\{1, \dots, n \right\}\) for which \(b_i \neq c_i\). Because the number of permutations may be very large, please give it modulo \(10^9 + 9\).

제약
입력 형식

The input starts with an integer \(1 \leq n \leq 5000\). Then follows a single line with \(n\) integers \(a_1, \ldots, a_n\), with \(0 \leq a_i \leq 10^9\) for all \(i\).

출력 형식

Print a single integer: the number of entirely unsorted sequences you can make by permuting the \(a_i\), modulo \(10^9 + 9\).

예제 1
입력
4
0 1 2 3
출력
14
예제 2
입력
5
1 1 2 1 1
출력
1
예제 3
입력
13
1 2 3 4 5 6 7 8 9 10 11 12 13
출력
298600727
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2018

평가 및 의견

E. Entirely Unsorted Sequences

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

E. Entirely Unsorted Sequences

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8