Submission #1100662

#TimeUsernameProblemLanguageResultExecution timeMemory
1100662vjudge1Swap (BOI16_swap)C++17
0 / 100
1 ms336 KiB
//#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define all(x) x.begin(), x.end() const int N = 500001; using namespace std; ll n, p[N], m, a, b, c; signed main (){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++){ cin >> p[i]; } p[n + 1] = 1e9; p[n + 2] = 1e9; for (int i = 1; i <= n / 2; i++){ if (i % 2 == 1){ if (min (p[i + i], p[i + i + 1]) < p[i]){ if (p[i + i] < p[i + i + 1]){ swap (p[i], p[i + i]); } else{ swap (p[i], p[i + i + 1]); } if (p[i + i] > p[i + i + 1]){ swap (p[i + i], p[i + i + 1]); } } } else{ if (min (p[i + i], p[i + i + 1]) < p[i]){ if (p[i] < p[i + 1]){ swap (p[i], p[i + 1]); } if (p[i + i] < p[i + i + 1]){ swap (p[i], p[i + i]); } else{ swap (p[i], p[i + i + 1]); } if (p[i + i] > p[i + i + 1]){ swap (p[i + i], p[i + i + 1]); } } } // for (int y = 1; y <= n; y++){ // cout << p[y] << ' '; // } // cout << '\n'; } for (int i = 1; i <= n; i++){ cout << p[i] << ' '; } }
#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...