Submission #887306

# Submission time Handle Problem Language Result Execution time Memory
887306 2023-12-14T08:52:24 Z vjudge1 Swap (BOI16_swap) C++17
0 / 100
43 ms 348 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define pb              push_back
#define F               first
#define S               second
#define len(x)          (int)x.size()
#define all(x)          x.begin(),x.end()
#define file            freopen("txt.in", "r", stdin);freopen("txt.out", "w", stdout);
#define kill(x)         {cout << x << '\n'; return 0;}
#define int             long long

const int maxn = 1e5 + 5, LG = 21, MOD = 1e9+7;// 998244353
const ll inf =  1061109567;

int n, a[LG];
string cur, tmp, s;


inline void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        cur.pb(a[i] + 48);
    }
    s = cur;
    for(int i = 0; i < (1<<(n-1)); ++i) {
        tmp = s;
        for(int j = 0; j < LG; ++j) {
            if((1<<j) & i) {
                swap(tmp[(j+2)-1], tmp[(j+2)/2-1]);
             }
        }
        if(tmp < cur) cur = tmp;
        tmp = "";
    }
    
    for(int i = 0; i < len(cur); ++i){
        cout << cur[i] << ' ';
    }
}

signed main() { 
    ios::sync_with_stdio(0), cin.tie(0);
    solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -