Submission #1008962

#TimeUsernameProblemLanguageResultExecution timeMemory
1008962ArgoCahayaSwap (BOI16_swap)C++14
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> #define ll long long #define endl "\n" #define fi first #define se second #define pb push_back #define pll pair<long long, long long> #define loop(i,n) for(int i=1;i<=n;i++) #define loop0(i,n) for(int i=0;i<n;i++) using namespace std; //pbds template //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //template <class T> //using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; void solve(){ ll n; cin >> n; ll arr[n+5]; for(int i=1;i<=n;i++){ cin >> arr[i]; } set<ll> s[n+5]; for(int i=1;i<=n/2;i++){ s[i].insert(arr[i]); s[i].insert(arr[i*2]); s[i*2].insert(arr[i]); s[i*2].insert(arr[i*2]); if(i*2+1<=n){ s[i*2+1].insert(arr[i]); s[i*2+1].insert(arr[i*2]); s[i*2+1].insert(arr[i*2+1]); s[i*2].insert(arr[i*2+1]); s[i].insert(arr[i*2+1]); } for(auto j:s[i]){ s[i*2].insert(j); if(i*2+1<=n) s[i*2+1].insert(j); } } // cout << "DEBUG" << endl; ll ans[n+5] = {0}; ll occ[n+5] = {0}; for(int i=1;i<=n;i++){ for(auto j:s[i]){ if(occ[j]==1) continue; cout << j << ' '; occ[j] = 1; } } cout << endl; } int main(){ // ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tc = 1; // cin >> tc; while(tc--){ solve(); } }

Compilation message (stderr)

swap.cpp: In function 'void solve()':
swap.cpp:46:5: warning: unused variable 'ans' [-Wunused-variable]
   46 |  ll ans[n+5] = {0};
      |     ^~~
#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...