Doctor Strange and the Swap
InterviewTime limit2sMemory limit1024 MB
Find two positions whose swap puts even numbers on even positions and odd numbers on odd positions, or report -1 -1 if no swap works.
- Level
Easy2 of 10
- Topics
- Implementation, Brute force, Array
- Solved
- No attempts yet
Problem
Doctor Strange has a garden where flower pots are lined up in a row. Each pot has a number written on it. The pot at position has the number , so the pots form an array .
On the weekend, Doctor Strange swaps the pots at two different positions and (). He likes patterns, so he wants even positions to hold even numbers and odd positions to hold odd numbers after the swap.
Determine whether exactly one swap of two elements at different positions can turn into an array that satisfies this condition.
Input
The first line contains a natural number (). The next line contains natural numbers (), the numbers written on the pots.
Output
Print and , the positions of the two elements to swap, so that the condition holds. If there are several answers, print any of them. If no swap achieves this, print -1 -1.