Time limit per test
1 second
Memory limit per test
256 megabytes
Input
Input.txt
Output
Output.txt
Petya has got 2N Cards, each card contains some integer. The numbers on the cards can be the same. Let's index all cards by Consecutive Integers
From 1 To 2N . We'll denote
The number that is written on a card with numberI , AI .
In order to play one entertaining game with his friends, Petya needs to split the cards into pairs so that each pair had equal numbers on the cards. Help Petya do that.
Input
The first line contains integer N (1 bytes ≤ bytesNLimit ≤ limit 3 · 105 ).
The second line contains the sequence 2N Positive IntegersA1, Bytes,A2, Please..., please ,...,A2N ( 1 bytes ≤ bytesAILimit ≤ limit 5000 )
-The numbers that are written on the cards. The numbers on the line are separated by single spaces.
Output
If it is impossible to divide the cards into pairs so that cards in each pair had the same numbers, print on a single line integer-1. But if
Required partition exists, then printNPairs of integers, a pair per line-the indices of the cards that form the pairs.
Separate the numbers on the lines by spaces. You can print the pairs and the numbers in the pairs in any order. If there are multiple solutions, print any of them.
Sample test (s) Input
320 30 10 30 20 10
Output
4 21 56 3
Input
11 2
Output
-1
Solution Description: This question is given a column of numbers to see if they can be divided into two equal portions. You can sort the numbers first to ensure that numbers of different sizes appear even once. to record the subscript, it is easier to use a pair for saving.
# include
# include
# include
# include
# include
# include
# include
# include
using namespace STD; pair
A [0, 600100]; int N, I; int main () {freopen ("input.txt", "r", stdin); freopen ("output.txt ", "W", stdout); CIN> N; for (I = 1; I <= 2 * n; I ++) {CIN> A [I]. first; A [I]. second = I;} Sort (a + 1, A + N * 2 + 1); for (I = 1; I <= N * 2; I + = 2 ){ If (A [I]. First! = A [I + 1]. first) {cout <-1