제출 #1121351

#제출 시각아이디문제언어결과실행 시간메모리
1121351PagodePaivaSwap (BOI16_swap)C++17
0 / 100
3 ms6480 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); } } vector <int> res; for(int i = n;i >= 1;i--){ sort(v[i].begin(), v[i].end()); reverse(v[i].begin(), v[i].end()); /*for(auto x : v[i]){ cout << x << ' '; } cout << '\n';*/ for(auto x : v[i]){ if(mark[x] == 0){ res.push_back(x); mark[x] = 1; break; } } } reverse(res.begin(), res.end()); for(auto x : res){ cout << x << ' '; } 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...