Submission #1121339

#TimeUsernameProblemLanguageResultExecution timeMemory
1121339PagodePaivaSwap (BOI16_swap)C++17
0 / 100
4 ms4948 KiB
#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 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...