SnowflakeOA #46
Simple Array Rotation Game
Estimated EasyJudge-ready
Topics (AI-labelled)In-place Arrays
The array consists of distinct positive integers. Each query independently rotates the original array to the left r times and returns the new 0-based index of the maximum element; rotations do not accumulate across queries.
Input
The first line contains n m, the second line contains n distinct array values, and the third line contains m rotation counts. 1≤n,m≤500000, 1≤array value≤10⁹, 0≤rotation count≤10⁹.
Output
First output m, then output m 0-based indices of the maximum element.
Example 1
Input:
3 3
1 2 3
1 2 3
Output:
3
1 0 2
Example 2
Input:
3 3
9 1 2
0 1 4
Output:
3
0 2 2
Example 3
Input:
1 2
7
0 1000000000
Output:
2
0 0
Example notes
The answers to the three public examples are, in order: 3 1 0 2; 3 0 2 2; 2 0 0. The examples were checked by independent enumeration, state search, or direct simulation.
Editorial
Loading solution…