CF1726G A Certain Magical Party

题目描述

## 题意翻译 聚会上有 $n$ 个人,第 $i$ 个人有一个开心指数 $a_i$ 。 每个人都有一种确定的个性,这种个性可以用一个二进制整数 $b$ 来表示。如果 $b=0$ ,那么意味着如果他将一个故事讲给一个开心指数比他低的人,他的开心指数就会增加。如果 $b=1$ ,那么意味着如果他将一个故事讲给一个开心指数比他高的人,他的开心指数就会增加。 让我们定义讲故事的顺序为从左到右。接下来发生以下过程:从左至右的每个人给除他以外的所有人听。请注意,当这发生时,**所有的快乐指数保持不变**。当这个人讲完以后,他会根据他的个性计算目前开心指数比他少/多的人数,他的开心指数会加上这个量。请注意,**只有当前的人的快乐指数增加**。 作为聚会的组织者,你不希望任何人伤心地离开。因此,你需要计算可以使得全部 $n$ 人在这个过程的最后开心指数都相同的发言顺序的数量。如果两个发言顺序中至少有一个人的位置不同,则这两个发言顺序是不同的。

输入格式

输出格式

说明/提示

Here is the explanation for the first example. One valid speaking order is $ [2,1,4,3] $ (here, we have written the indices of each person). Each step shows the current happiness values and results. Step $ 1 $ : $ [1,2,4,4] $ $ \rightarrow $ Person $ 2 $ tells the story to others. Since his kind of personality is $ 1 $ , his happiness increases by $ 2 $ since persons $ 3 $ and $ 4 $ have strictly greater happiness. Step $ 2 $ : $ [1,4,4,4] $ $ \rightarrow $ Person $ 1 $ tells the story to others. Since his kind of personality is $ 1 $ , his happiness increases by $ 3 $ since persons $ 2 $ , $ 3 $ and $ 4 $ have strictly greater happiness. Step $ 3 $ : $ [4,4,4,4] $ $ \rightarrow $ Person $ 4 $ tells the story to others. Since his kind of personality is $ 0 $ , his happiness increases by $ 0 $ since no one has strictly lesser happiness. Step $ 4 $ : $ [4,4,4,4] $ $ \rightarrow $ Person $ 3 $ tells the story to others. Since his kind of personality is $ 0 $ , his happiness increases by $ 0 $ since no one has strictly lesser happiness. At the end, everyone has equal happiness. Note that $ [2,1,3,4] $ is also a valid answer for this example. It can be shown that there is no valid ordering for the second example.