Submission #199035

# Submission time Handle Problem Language Result Execution time Memory
199035 2020-01-28T17:51:49 Z stefdasca Swap (BOI16_swap) C++14
0 / 100
5 ms 376 KB
#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 mn(int a, int b)
{
    int va = n+1;
    if(a > n)
        va = min(va, n+1);
    else
        va = min(va, v[a]);
    if(b > n)
        va = min(va, n+1);
    else
        va = min(va, v[b]);
    return va;
}
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] = n+1;
    for(int i = 1; i + i <= n; ++i)
    {
        if(v[i] < v[i+i] && v[i] < v[i+i+1])
            continue;
        if(v[i+i] < v[i] && v[i] < v[i+i+1])
            swap(v[i], v[i+i]);
        else
            if(v[i+i+1] < v[i] && v[i] < v[i+i])
            {
                if(mn(i*4, i*4+1) > v[i])
                    swap(v[i], v[i+i]);
                swap(v[i+i+1], v[i]);
            }
            else
                if(v[i+i] < v[i+i+1] && v[i+i+1] < v[i])
                    swap(v[i], v[i+i]);
                else
                    if(v[i+i+1] < v[i+i] && v[i+i] < v[i])
                    {
                        if(mn(i*4, i*4+1) > v[i+i])
                            swap(v[i], v[i+i]);
                        swap(v[i+i+1], v[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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -