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

31119번 - Permutation Pattern 다국어

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

문제

A sequence $a_1, \dots, a_m$ of $m$ distinct numbers is called *without 231* if there is **no** triples $(i, j, k)$ where 1ドル \leq i < j < k \leq m$ and $a_k < a_i < a_j$.

Bobo has a permutation $p_1, \dots, p_n$ of 1,ドル \dots, n,ドル and he can remove some (possibly none, but not all) elements from the permutation. Find the number of sequences without 231ドル$ among $(2^n - 1)$ resulting permutations.

입력

The input consists of several test cases terminated by end-of-file. For each test case,

The first line contains an integer $n$.

The second line contains $n$ integers $p_1, \dots, p_n$.

출력

For each test case, output an integer which denotes the number of sequences.

제한

  • 1ドル \leq n \leq 50$
  • 1ドル \leq p_i \leq n$ for each 1ドル \leq i \leq n$
  • In each input, the sum of $n$ does not exceed 500ドル$.

예제 입력 1

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

예제 출력 1

3
7
11

노트

출처

Contest > Open Cup > 2020/2021 Season > Stage 18: Grand Prix of Beijing J번

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

출처

대학교 대회

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

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