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;
const int N = 200010;
vector <int> v[N];
int p[N];
int mark[N];
int main(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> p[i];
v[i].push_back(p[i]);
}
for(int i = 2;i <= n;i++){
set <int> s;
for(auto x : v[i]){
s.insert(x);
}
for(auto x : v[i/2]){
s.insert(x);
}
v[i/2].clear();
v[i].clear();
for(auto x : s){
v[i/2].push_back(x);
v[i].push_back(x);
}
}
for(int i = 1;i <= n;i++){
for(auto x : v[i]){
if(mark[x] == 0){
cout << x << ' ';
mark[x] = 1;
break;
}
}
}
cout << '\n';
}
# | 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... |