Pagini recente » Cod sursa (job #2612471) | Cod sursa (job #2524795) | Cod sursa (job #1813702) | Cod sursa (job #1017086) | Cod sursa (job #800915)
Cod sursa(job #800915)
/*
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;
}