Pagini recente » Cod sursa (job #2301409) | Cod sursa (job #3161089) | Cod sursa (job #746309) | Cod sursa (job #519391) | Cod sursa (job #2399186)
#include <bits/stdc++.h>
using namespace std;
const int DIM = 600005;
pair<int, int> arr[DIM];
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == 4096) {
sp = 0;
fread(buff, 1, 4096, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[4096]();
sp = 4095;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
InParser& operator >> (long long &n) {
char c;
n = 0;
while (!isdigit(c = read_ch()) && c != '-');
long long sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
} in("congr.in");;
int main(void) {
freopen("congr.out", "w", stdout);
int p; in >> p; long long sum = 0;
for (int i = 1; i <= 2 * p - 1; ++i) {
in >> arr[i].first; arr[i].second = i;
if (i <= p) {
sum += arr[i].first; } }
srand(unsigned(time(0)));
while (sum % p) {
int p1 = rand() % p + 1,
p2 = rand() % (p - 1) + (p + 1);
sum = sum - arr[p1].first + arr[p2].first;
swap(arr[p1], arr[p2]); }
for (int i = 1; i <= p; ++i) {
cout << arr[i].second << " "; }
return 0; }