Submission #563351

#TimeUsernameProblemLanguageResultExecution timeMemory
563351ngpin04Swap (BOI16_swap)C++14
0 / 100
1 ms1876 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "" #define bit(x) (1LL << (x)) #define getbit(x, i) (((x) >> (i)) & 1) #define ALL(x) (x).begin(), (x).end() using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return l + rd() % (r - l + 1); } const int N = 4e5 + 5; const int oo = 1e9; const long long ooo = 1e18; const int mod = 1e9 + 7; // 998244353; const long double pi = acos(-1); int pos[N]; int val[N]; int a[N]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = n + 1; i <= 2 * n + 1; i++) a[i] = oo; for (int i = 1; i <= n; i++) { val[a[i]] = i; pos[i] = i; } memset(a, 0, sizeof(a)); a[0] = oo; for (int i = 1; i <= n; i++) { int cur = val[i]; if (!a[cur >> 1]) { a[cur >> 1] = i; pos[cur >> 1] = pos[cur]; } else a[pos[cur]] = i; } for (int i = 1; i <= n; i++) cout << a[i] << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...