Pagini recente » Cod sursa (job #3225232) | Cod sursa (job #2283886) | Cod sursa (job #1761592) | Cod sursa (job #2109872) | Cod sursa (job #800928)
Cod sursa(job #800928)
/*
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;
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=1+rand()%N;
int y=1+N+rand()%(N-1);
S-=V[P[x]];
S+=V[P[y]];
P[x]^=P[y]^=P[x]^=P[y];
}
for(register int i=1;i<=N;++i)
{
fout<<P[i]<<" ";
}
fout.close();
return 0;
}