#include<stdio.h> int main() { int i,n,m=1,t,a[600001],b[5001]={0}; freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); scanf("%d",&n); for(i=1;i<=2*n;i++) { scanf("%d",&t); if(b[t]==0)b[t]=i; else {a[m]=b[t],a[m+1]=i;b[t]=0;m+=2;} } if((m-2*n)!=1)printf("-1"); else { for(i=1;i<=2*n;i+=2) printf("%d %d\n",a[i],a[i+1]); } return 0; }
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)