# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199022 | stefdasca | Swap (BOI16_swap) | C++14 | 5 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
// #define fisier 1
using namespace std;
typedef long long ll;
int n, v[200002];
int main()
{
#ifdef fisier
ifstream f("input.in");
ofstream g("output.out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; ++i)
cin >> v[i];
v[n+1] = 2000000;
for(int i = 1; i + i <= n; ++i)
{
if(v[i] < v[i+i] && v[i] < v[i+i+1])
continue;
if(v[i] < v[i+i] && v[i+i+1] < v[i+i])
{
if((i+i) * 2 <= n && v[(i+i) * 2] < v[i+i] || (i+i)*2+1 <= n && v[(i+i)*2+1] < v[i+i]);
else
swap(v[i], v[i+i]);
swap(v[i], v[i+i+1]);
}
else
if(v[i+i+1] < v[i])
{
swap(v[i], v[i+i+1]);
}
else
if(v[i+i] < v[i])
{
swap(v[i], v[i+i]);
}
// for(int j = 1; j <= n; ++j)
// cout << v[j] << " ";
// cout << '\n';
}
for(int i = 1; i <= n; ++i)
cout << v[i] << " ";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |