# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394786 | Nima_Naderi | Swap (BOI16_swap) | C++14 | 41 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
typedef int ll;
const ll MXN = 20 + 10;
ll n;
ll A[MXN], B[MXN], C[MXN], ANS[MXN];
bool check(){
for(int i = 1; i <= n; i ++){
if(ANS[i] == B[i]) continue;
return (B[i] < ANS[i]);
}
return 0;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i ++) cin >> A[i];
memcpy(ANS, A, sizeof A);
if(n > 20) return 0;
for(int mask = 0; mask < (1LL << (n - 1)); mask ++){
memcpy(B, A, sizeof A);
for(int i = 2; i <= n; i ++){
if((mask >> (i - 2)) & 1LL){
swap(B[i], B[i / 2]);
}
}
if(check()){
memcpy(ANS, B, sizeof B);
}
}
for(int i = 1; i <= n; i ++) cout << ANS[i] << ' '; cout <<'\n';
return 0;
}
//! N.N
Compilation message (stderr)
# | 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... |