#P2524. Uim的情人节礼物·其之弐
Uim的情人节礼物·其之弐
Description
Prequel: see Luogu P2525.
Uim successfully delivered gifts to girls in some order and maintained their harmony.
Now Uim wants to know the lexicographic rank of the final order he chose among all gift-giving orders for girls. The order can be viewed as a permutation of .
Input Format
The first line contains an integer .
The second line contains an integer , representing the given permutation.
Output Format
Output a single integer, indicating its position in lexicographic order.
3
231
4
Hint
.
Please note that the permutation in the input has no spaces.
Translated by ChatGPT 5
京公网安备 11011102002149号