Submission #1121345

#TimeUsernameProblemLanguageResultExecution timeMemory
1121345PagodePaivaSwap (BOI16_swap)C++17
10 / 100
62 ms512 KiB
#include<bits/stdc++.h> using namespace std; const int N = 21; int v[N]; int at[N]; int res[N]; int main(){ int n; cin >> n; for(int i = 1;i <= n;i++){ cin >> v[i]; res[i] = v[i]; } for(int mask = 0;mask < (1<<n);mask++){ for(int j = 1;j <= n;j++){ at[j] = v[j]; if(j == 1) continue; if((1<<(j-1))&mask){ swap(at[j], at[j/2]); } } for(int j = 1;j <= n;j++){ if(at[j] < res[j]){ for(int j = 1;j <= n;j++){ res[j] = at[j]; } break; } if(at[j] > res[j]) break; } } for(int i = 1;i <= n;i++){ cout << res[i] << ' '; } 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...