Odd Gnome
Time limit2sMemory limit512 MB
For each group of unique IDs whose non-king elements increase by exactly one, output the 1-based position of the single out-of-order gnome.
- Level
Easy3 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
According to legend, gnomes live underground in burrows called gnome holes. They dig up and eat the roots of plants there, and they leave small heaps of earth around gardens, which does real damage.
Mrs. W is tired of the damage, so she clears her garden of gnomes regularly by throwing them over the fence. Throwing them one at a time is far too much work because there are so many. Luckily this species follows its king no matter what, so if she throws only the king over the fence, every other gnome in that group leaves with him.
How does Mrs. W spot the king in a group of gnomes? She knows that gnomes line up in a fixed order, and the king, being special, is the only gnome who breaks that order.
A group of gnomes has these properties.
- Each group holds exactly one king.
- Apart from the king, the gnomes line up in strictly increasing order of ID.
- The king is the only gnome out of that order.
- The king likes to hide, so he never stands first or last in the group.
Help Mrs. W find every king.
Input
The first line holds the number of gnome groups (). Each of the next lines describes one group. The line starts with the number of gnomes in that group, (), followed on the same line by space separated IDs in the order the gnomes stand. Within a group every ID, the king's included, is distinct, and each value is between and . Excluding the king, each ID is exactly larger than the ID before it.
Output
For each group, print the position of the king in that group on its own line. The gnome standing first in line is at position .