#DSU0000086. Danh sách bài hát (Playlist)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Danh sách bài hát (Playlist)
Playlist
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are songs on a cyclic playlist, numbered from to , with genres . Listening begins at song , continues through the remaining songs in order, and wraps to the first song after the last.
After two consecutively listened songs have genres and , if , the second of those songs is removed. Listening resumes at the next remaining song, and the listening history is reset: two more songs must be heard before another deletion. When only one song remains, listening to it twice consecutively still counts.
The process ends when no more songs can be deleted. Output the number of deleted songs followed by their original indices in deletion order.
Input
The first line contains . The second line contains .
Output
Print , the number of deletions, followed by the original indices of the deleted songs in order.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Example
Input
5
5 9 2 10 15
Output
2 2 3
Explanation
Song is removed because . Later song is also removed. No further deletions are possible.