Pagini recente » Cod sursa (job #566036) | Cod sursa (job #972015) | Cod sursa (job #1745051) | Cod sursa (job #754052) | Cod sursa (job #1239582)
#include <fstream>
#include <ctime>
#include <algorithm>
#define MOD 8096
using namespace std;
ifstream fin ("congr.in");
ofstream fout ("congr.out");
int P, A[600010], B[600010];
char Parse[MOD+16], *now;
long long sum;
void Verif()
{
if (*now == 0)
{
fin.get(Parse, MOD, '\0');
now = Parse;
}
}
int Get()
{
while (*now < '0' || *now > '9')
{
++now;
Verif();
}
int number = 0;
while (*now >= '0' && *now <= '9')
{
number = number * 10 + (*now - '0');
++now;
Verif();
}
return number;
}
int main()
{
now = Parse;
Verif();
P = Get();
int pp = P*2;
for (int i=1; i<pp; i++)
{
A[i] = Get();
B[i] = i;
if (i <= P) sum += A[i];
}
srand(time(0));
while (sum % P)
{
int x1 = 1 + rand() % P;
int x2 = 1 + P + rand() % (P - 1);
sum = sum + A[B[x2]] - A[B[x1]];
swap (B[x1], B[x2]);
}
for (int i=1; i<=P; i++) fout << B[i] << ' ';
fout << '\n';
fout.close();
return 0;
}