#P8927. 「GMOI R1-T4」Rain
「GMOI R1-T4」Rain
Background
Praying for Rain
Grandpa Jade Emperor is also surnamed Zhang,
so why are you making things hard for my Zhang *Chang?
If it does not rain within three days,
first I will tear down the Dragon King Temple,
then I will use cannons to blow up your mother.
If it still does not rain, Marshal Zhang will blow up all religious sites across Asia!
Because Hakurei Shrine can be seen from the outside world, it naturally cannot escape this either. Reimu is very anxious and plans to use her ancestral secret technique to pray for rain...
Problem Description
To prevent the shrine from being "blasted by cannons", Reimu needs to pray for rain.
To pray for rain, she needs to build magic circles on a straight road, numbered .
You are given an array of length , meaning that the magic circles are built at positions to . What you need to do is assign the numbers to the magic circles.
Reimu needs to test the effect of the circles. She will walk from circle to circle , from to , and so on until she reaches circle , then walk back from circle to circle .
Due to the special effect of the circles, the distance from the -th to the -th is . In particular, the distance from circle back to circle is . Here are two given constants, and are the positions of the two circles.
Reimu wants you to find the maximum walking distance, and output a corresponding arrangement of the positions of circles numbered from to . (If there are multiple answers, output any one.)
Input Format
The first line contains an integer , representing the number of magic circles.
The second line contains two integers , representing the multiplier constants.
The third line contains integers, representing the array .
Output Format
The first line contains one integer, representing the answer.
The second line contains integers, representing a permutation of the positions , output in order from circle to circle .
10
2 3
1 2 3 4 5 6 7 8 9 10
131
5 6 7 1 8 2 9 3 10 4
Hint
This problem uses SPJ.
The input size is large; it is recommended to use faster input methods.
For of the testdata, , , .
| ID | Score | |||
|---|---|---|---|---|
Translated by ChatGPT 5