Pagini recente » Cod sursa (job #735405) | Cod sursa (job #423139) | Cod sursa (job #2322998) | Cod sursa (job #2910121) | Cod sursa (job #1480636)
#include <fstream>
const char IN [ ] = "congr.in" ;
const char OUT[ ] = "congr.out" ;
const unsigned MAX_N = 300000U;
using namespace std;
ifstream cin ( IN );
ofstream cout ( OUT );
unsigned a [ ( MAX_N << 1 ) - 1 ];
unsigned pos [ (MAX_N << 1 ) - 1 ];
unsigned xor128 ( void )
{
static unsigned x = 123456789U;
static unsigned y = 362436069U;
static unsigned z = 521288629U;
static unsigned w = 88675123U;
unsigned t = x ^ ( x << 11U );
x = y;
y = z;
z = w;
return w = w ^ ( w >> 19U ) ^ ( t ^ ( t >> 8U ) );
}
int main ( void )
{
unsigned n;
unsigned long long s = 0ULL;
cin >> n;
for ( register unsigned i = 0; i < n; i ++ )
{
cin >> a [ i ];
pos [ i ] = i;
s += a [ i ];
}
for ( register unsigned i = 1; i < n; i ++ )
{
cin >> a [ i + n - 1 ];
pos [ i + n - 1 ] = i + n - 1;
}
cin.close ( );
while ( s - s / n * n )
{
unsigned toSwap = xor128 ( ) % n;
unsigned with = n + xor128 ( ) % ( n - 1 );
s += a [ with ] - a [ toSwap ];
swap ( a [ with ], a [ toSwap ] );
swap ( pos [ with ], pos [ toSwap ] );
}
for ( register unsigned i = 0; i < n; i ++ )
{
cout << pos [ i ] + 1 << ' ';
}
cout << '\n';
cout.close ( );
return 0;
}