#P5780. [CTSC2011] 排列

    ID: 4748 远端评测题 3000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2011WC/CTSC/集训队Special JudgeO2优化

[CTSC2011] 排列

Description

Momo really likes finding patterns and filling in numbers. For example, 1,4,7,(),1,4,7,( ),\cdots: the difference between adjacent numbers is 33, so the number in the parentheses should be 1010. Another example is 3,6,12,(),3,6,12,( ),\cdots: each number is twice the previous one, so the number in the parentheses should be 2424.

After playing this kind of game for many years, Momo got tired of arithmetic sequences and geometric sequences. When she sees the sequence 1,2,,n1,2,\cdots,n, she wants to change its order as little as possible so that there is no subsequence with common difference AA or common ratio BB.

More specifically, given integers n,A,Bn,A,B, find a permutation P=(P1,P2,,Pn)P=(P_1,P_2,\cdots,P_n) of 11 to nn such that i,j{1,2,,n}\forall i,j \in \{1,2,\cdots,n\}, if i<ji<j and Pi<PjP_i<P_j, then PjPi+AP_j \neq P_i+A and PjPi×BP_j \neq P_i \times B. The degree to which the permutation PP keeps the original order is defined as SS:

$$S = \sum\limits_{1 \le i \le j \le n , P_i<P_j} (P_j-P_i)$$

Under the above constraints, please make the value of SS as large as possible.

Input Format

The first line contains three positive integers n,A,Bn,A,B, with meanings as described above. Adjacent numbers are separated by one space.

Output Format

The first line contains nn integers, the permutation PP you found. Adjacent numbers are separated by spaces.

4 3 2

4 2 1 3

Hint

Sample Explanation

For this permutation, S=3S = 3, which is the maximum possible SS when n=4,A=3,B=2n=4,A=3,B=2.


Scoring

Each test point is scored independently.

For each test point, if your output is invalid, such as wrong file format, or the output solution does not satisfy the requirements, then you get 00 points for that test point.

Otherwise, let the SS value of your permutation be aa, and the SS value of the permutation we provide be bb. Your score for that test point is:

  • If aba \le b, you get 1010 points.
  • Otherwise, the score is:

max{[10×(exp(ab2)],1}\max \{ [10 \times ( \exp (\frac{a}{b}-2)],1 \}


Constraints

There are 1010 test points in total. The constraints are:

Test Point ID nn AA BB
11 30\le 30 n\le n
22 60\le 60 AmodB0A\bmod B\not =0 4\ge 4
33 70\le 70 5\ge 5
44 80\le 80 6\ge 6
55 90\le 90 7\ge 7
66 n\le n =1=1
7,87,8 5\le 5 n\le n
99 =60=60 =21=21 =3=3
1010 =90=90 =18=18 =2=2

In all input data, both AA and BB are positive integers not exceeding nn.

Translated by ChatGPT 5