Submission #199022

#TimeUsernameProblemLanguageResultExecution timeMemory
199022stefdascaSwap (BOI16_swap)C++14
0 / 100
5 ms376 KiB
#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)

swap.cpp: In function 'int main()':
swap.cpp:39:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
             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]);
                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...