Pagini recente » Cod sursa (job #968866) | Cod sursa (job #1040975) | Cod sursa (job #2355876) | Cod sursa (job #892846) | Cod sursa (job #2340366)
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'
using namespace std;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef long long ll;
typedef unsigned long long ull;
template <class T> void uin (T &a, T b) {a = min (a, b);}
template <class T> void uax (T &a, T b) {a = max (a, b);}
ifstream f ("congr.in");
ofstream g ("congr.out");
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL_DEFINE
freopen (".in", "r", stdin);
#endif
srand (time (0));
int n, sum = 0;
f >> n;
vi v (2 * n), ans (2 * n, 0);
for (int i = 1; i <= 2 * n - 1; ++i) {
f >> v[i];
ans[i] = i;
if (i <= n) (sum += v[i]) %= n;
}
auto random = [&] (int lo, int hi) {
return lo + rand() % (hi - lo + 1);
};
while (sum != 0) {
int sub = random (1, n);
int add = random (n + 1, 2 * n - 1);
(sum += v[add] - v[sub]) %= n;
swap (v[sub], v[add]);
swap (ans[sub], ans[add]);
}
for (int i = 1; i <= n; ++i) {
g << ans[i] << ' ';
}
g << '\n';
f.close();
g.close();
#ifdef LOCAL_DEFINE
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}