Pagini recente » Cod sursa (job #2629636) | Cod sursa (job #344196) | Cod sursa (job #679099) | Cod sursa (job #333960) | Cod sursa (job #800923)
Cod sursa(job #800923)
/*
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],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];
}
S%=N;
S=(S+N)%N;
while(S)
{
int x=1+rand()%N;
int y=N+1+rand()%(N-1);
S=(S-V[P[x]]+V[P[y]]+N)%N;
int t=P[x];
P[x]=P[y];
P[y]=t;
}
for(register int i=1;i<=N;++i)
{
fout<<P[i]<<" ";
}
fout.close();
return 0;
}