Untitled

mail@pastecode.io avatar
unknown
c_cpp
21 days ago
941 B
6
Indexable
Never
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f(i, x, n) for (int (i) = x; (i) < (n); i++)

int main()
{
    int n;
    bool b = false;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    cin >> n;
    unordered_map<int, vector<int>> m;
    unordered_map<int, vector<int>>::iterator itr;
    f(i, 1, (2*n)+1) 
    {
        int t;
        cin >> t;
        m[t].push_back(i);
    } 
    for (auto itr = m.begin(); itr != m.end(); itr++) 
    {
        if(itr->second.size() % 2 == 0) {b = true;} 
        else 
        {
            b = false;
            break;
        }
    }
    if(!b){cout << -1;}
    else 
    {
        for (auto itr = m.begin(); itr != m.end(); itr++)
        {
            for(int i = 0; i < itr->second.size(); i += 2)
            {cout << itr->second[i] << " " << itr->second[i+1] << endl;}
        }
    }
}
Leave a Comment