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

9814번 - Coding of Permutations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB47242455.814%

문제

Write a program that gives us the ordinal position d(P) of any rank-n permutation P=(p1,p2卲n) in the dictionary without producing all the rank-n permutations in order, where pi{1,2,3,...,n},n<=50. When n=4, the whole rank-4 permutation in lexicographical order and the code is shown in the following figure.

For example: if P=(2,3,4,1), then d(P)=10; if P=(4,2,1,3), then d(P)=21.

Rank - 4

Dictational Permutation

입력

(n, P): For more than one input in the input file, one line is for each input ,with -1 at the end. P is in the form of list.

출력

d(P): It should be in the form of a line with the outputs separated by commas.

제한

예제 입력 1

(4,(3,2,1,4))
(5,(3,5,1,2,4))
-1

예제 출력 1

15,67

힌트

출처

ICPC > Regionals > Asia East Continent > China > Xi'an > Xi'an Regional Contest 2002 B번

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

출처

대학교 대회

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

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