# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56189 | 2018-07-10T08:14:03 Z | 정원준(#1583) | Swap (BOI16_swap) | C++11 | 3 ms | 376 KB |
#include <bits/stdc++.h> #define L long long using namespace std; L n; L a[200020]; L go(L val,L loc){ if(loc*2>n) return loc; if(loc*2+1>n) { if(val>a[loc*2]) return loc; else return loc*2; } else { if(val<a[loc*2]&&val<a[loc*2+1]) return loc; if(val<a[loc*2]&&val>a[loc*2+1]) return go(val,loc*2+1); if(val>a[loc*2]&&val<a[loc*2+1]) return go(val,loc*2); else return min(go(val,loc*2),go(val,loc*2+1)); } } int main() { scanf("%lld",&n); L i; for(i=1;i<=n;i++) { scanf("%lld",&a[i]); } for(i=1;i<=n/2;i++) { if(i*2+1>n) { if(a[i]>a[i*2]) { swap(a[i],a[i*2]); } } else { if(a[i*2]<a[i]&&a[i*2]<a[i*2+1]) { swap(a[i],a[i*2]); } else if(a[i]<a[i*2]&&a[i]<a[i*2+1]) { continue; } else { L temp=go(a[i],i*2)<go(a[i],i*2+1); if(temp==1) swap(a[i],a[i*2]); swap(a[i],a[i*2+1]); } } } for(i=1;i<=n;i++) { printf("%lld ",a[i]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |