# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199000 | TadijaSebez | Swap (BOI16_swap) | C++11 | 6 ms | 504 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>
using namespace std;
#define mp make_pair
const int inf=1e9+7;
pair<int,int> min(pair<int,int> a,pair<int,int> b){return a<b?a:b;}
int main(){
int n;
scanf("%i",&n);
vector<int> a(n*2+5,inf),ans(n+1);
for(int i=1;i<=n;i++)scanf("%i",&a[i]);
for(int i=1;i<=n;i++){
pair<int,int> mn=min(mp(a[i<<1],i<<1),mp(a[i<<1|1],i<<1|1));
int j=i;
while(j){
mn=min(mn,mp(a[j],j));
if(j&1)mn=min(mn,mp(a[j^1],j^1));
j/=2;
}
ans[i]=mn.first;
a[mn.second]=inf;
printf("%i ",ans[i]);
assert(ans[i]>=1 && ans[i]<=n);
}
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... |