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

22798번 - Permutation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB33211578.947%

문제

Given a permutation of n elements (1, 2, ..., n): A = (a1, a2, . . . , an). We define a sequence P(A) = (p1, p2, . . . , pn−1) where pi = 0 if ai > ai+1 and pi = 1 if ai < ai+1. Given a permutation B, find the number of all permutations C where P(C) = P(B) including the permutation B itself.

입력

The input text file contains several tests, each on a separate line. The first number in the test is n (0 < n ≤ 1024) followed by n numbers representing the permutation all of them separated by a single space. The last line in the input contains only 0 and should not be processed.

출력

The output should be written on the standard output. For each line in the input (excluding the last one, 0) you should write the result i.e. the number of the permutations having the same value for P(A) when given the permutation A.

You may assume the result is less than 232.

제한

예제 입력 1

2 1 2
4 1 3 2 4
0

예제 출력 1

1
5

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2001 E번

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

출처

대학교 대회

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

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