Captain Shoaib is fighting against the zombies with his army. At some point, he realized that some of his soldiers are killing their own peers. After some investigation, he found some of his peers are actually imposter zombies and they are killing the original soldiers. To save his soldiers, Captain Shoaib needs to identify and kill the imposter zombies. But he doesn’t know how to identify the imposter zombies.
Captain Shoaib seeks help from Master Babu to save his army. Master Babu suggests a way to find the imposter zombies.
You are given an array which denotes the strength of the soldiers. For any , if there is any where and then both of the and are zombies.
Captain Shoaib wants to find all the imposter zombies and kill them. As a friend of Shoaib, you should help him to find the imposter zombies. You need to print the indices of the imposter zombies so that Shoaib can kill all of them at once. If no imposter zombies are found, print -1 instead.
The first line contains an integer n — the number of soldiers as well as the imposter zombies. The second line contains n space-separated integers — denoting the strengths of a soldier or a zombie.
Print the indices of the imposter zombies in ascending order. If no imposter zombies are found, print -1 instead.
5 6 8 10 8 9
0 1 3 4
The dataset is huge. Use faster I/O