您的位置:首页 > 其它

Cards with Numbers

2013-10-14 21:44 225 查看
http://codeforces.com/contest/254/problem/A

// File Name: cf_a.c
// Author: bo_jwolf
// Created Time: 2013年10月14日 星期一 21:22:17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<iostream>
#include<algorithm>

using namespace std;
const int maxn = 1000005;
struct node{
int x, y;
} num[ maxn ];

bool cmp( const node a, const node b ){
return a.x > b.x;
}

int main(){

freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n;
scanf( "%d", &n );
for( int i = 1; i <= 2 * n; ++i ){
scanf( "%d", &num[ i ].x );
num[ i ].y = i;
}
sort( num + 1, num + 2 * n + 1 , cmp );
//  for( int i = 1; i <=  2 * n; ++i )
// cout << num[ i ].x << endl;
for( int i = 1; i <= 2 * n ; i += 2 ){
if( num[ i ].x != num[ i + 1 ].x ){
puts( "-1" );
return 0;
}
}
for( int i = 1; i <= 2 * n; i += 2 ){
printf( "%d %d\n", num[ i + 1 ].y, num[ i].y );
}
return 0 ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Codeforces155 Div.2