#P6859. 蝴蝶与花
蝴蝶与花
Background
Amazing John had a dream that in his previous life he was a vast, misty butterfly.
Deep ravines and hidden orchids, rain falling into the boundless haze.
Pity its broken wings, sorrow for its stubborn obsession.
Jade-like flakes weave wings, flower dew sees it off.
A lonely butterfly shatters, the orchid withers yet still has feelings.
You do not know me, yet I still miss you.
Problem Description
Amazing John likes flowers very much.
There are flowers in Amazing John's garden, and every day he takes a walk in it.
For each flower, Amazing John will judge it as beautiful or not beautiful. A flower judged as beautiful has beauty value , and a flower judged as not beautiful has beauty value .
We can abstract these flowers as being on a straight line. During each walk, Amazing John may start from any flower and keep moving to the next flower, and end at any flower. Along the way, he sums up the beauty values of all flowers he passes (including the starting flower and the ending flower).
Now Amazing John wants to know whether there exists a walking plan such that the sum of beauty values from the -th flower to the -th flower is exactly .
To walk less, among all valid plans, Amazing John asks you to output the plan with the smallest .
Of course, to avoid the walk being too boring, Amazing John may change the beauty value of a flower at any time.
Each query is independent. That is, flowers counted in one query can still be counted in the next query.
Input Format
The first line contains two numbers , representing the number of flowers and the number of requests from Amazing John.
The second line contains numbers , where is the beauty value of the -th flower.
The next lines each describe either a query operation or a modification operation.
The query operation format is A s, asking whether there exists a walking plan such that the sum of beauty values is .
The modification operation format is C i val, meaning to change the beauty value of the -th flower to or .
Output Format
If there are operations of type A, the output should contain lines.
For each query, if there is a valid plan, output the left and right endpoint positions of that plan (if there are multiple plans, output the one with the smallest left endpoint). Otherwise, output none.
You should guarantee that .
5 4
1 2 2 1 1
A 5
C 1 2
A 5
A 233
1 3
2 4
none
Hint
: For testdata points , .
: For testdata points , .
: For testdata points , .
For of the testdata, . For each modification operation, .
For all testdata points, the time limit is and the memory limit is .
Translated by ChatGPT 5