Cod sursa(job #800913)

Utilizator ChallengeMurtaza Alexandru Challenge Data 22 octombrie 2012 21:32:12
Problema Congr Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.9 kb
/*
	PROB: congr
	LANG: C++
*/

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <ctime>

#define DEBUG

#ifndef DEBUG
	#define PRINT(x)
	#define D if(0)
#else
	#define PRINT(x) \
		cout<<#x<<":\t"<<x<<endl
	#define D if(1)
#endif

using namespace std;

const char InFile[]="congr.in";
const char OutFile[]="congr.out";
const int MaxN=600111;

ifstream fin(InFile);
ofstream fout(OutFile);

int N,V[MaxN],P[MaxN];
long long S;

inline int RandomInt(const int &a, const int &b)
{
	return a+(rand()%(b-a+1));
}

int main()
{
	srand((unsigned int)(time(NULL)));

	fin>>N;
	for(register int i=1;i<2*N;++i)
	{
		fin>>V[i];
		P[i]=i;
	}
	fin.close();
	
	for(register int i=1;i<=N;++i)
	{
		S+=V[i];
	}

	while(S%N)
	{
		int x=RandomInt(1,N);
		int y=RandomInt(N+1,(N<<1)-1);
		S-=V[P[x]];
		S+=V[P[y]];
		swap(P[x],P[y]);
	}

	for(register int i=1;i<=N;++i)
	{
		fout<<P[i]<<" ";
	}
	fout.close();
	return 0;
}