Submission #887286

# Submission time Handle Problem Language Result Execution time Memory
887286 2023-12-14T07:47:47 Z vjudge1 Swap (BOI16_swap) C++17
10 / 100
98 ms 2496 KB
/// Seeing the beauty through the...
/// Pain!
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define file_io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,k,n) for(int i = k; i < n; ++ i)
#define debf cout<<"(0-0)\n";
#define all(x) x.begin(), x.end()
#define dec(x) cout << fixed << setprecision(x);
#define pf push_front
#define ppf pop_front
#define dash " ------- "
#define what(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
//#define int short int
#define int long long
#define sz(s) (int) (s.size())
#define fl cout.flush()

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
typedef unsigned long long ull;
typedef long double ld;

template <class T> using max_heap = priority_queue <T, vector <T>, less <T> >;
template <class T> using min_heap = priority_queue <T, vector <T>, greater <T> >;
//template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

constexpr int MOD = 1e9 + 7, N = 2e5 + 8, M = 1e5 + 4, SQ = 300, INF = 1e15 + 8, LGN = 22, mod = 998244353, P = 131113;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], b[N];
string s = "z";

int32_t main(){
  fast_io;
  cin >> n;
  FOR (i, 1, n + 1){
    cin >> a[i];
    b[i] = a[i];
  }
  for (int i = 0; i < (1 << n - 1); ++ i){
    for (int j = 2; j <= n; ++ j){
      if ((1 << j - 2) & i){
        swap (b[j], b[j/2]);
      }
    }
    string t = "";
    for (int j = 1; j <= n; ++ j){
      t += (char)(b[j]);
      b[j] = a[j];
    }
    s = min (s, t);
  }
  for (int i = 0; i < s.size(); ++ i){
    cout << (int)(s[i]) << " ";
  }
  return 0;
}

// Yesterday is history
// Tomorrow is a mystery
// but today is a gift
// That is why it is called the present

Compilation message

swap.cpp: In function 'int32_t main()':
swap.cpp:55:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   55 |   for (int i = 0; i < (1 << n - 1); ++ i){
      |                             ~~^~~
swap.cpp:57:19: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   57 |       if ((1 << j - 2) & i){
      |                 ~~^~~
swap.cpp:68:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   for (int i = 0; i < s.size(); ++ i){
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2496 KB Output is correct
2 Correct 97 ms 2392 KB Output is correct
3 Correct 97 ms 2396 KB Output is correct
4 Correct 97 ms 2496 KB Output is correct
5 Correct 98 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2496 KB Output is correct
2 Correct 97 ms 2392 KB Output is correct
3 Correct 97 ms 2396 KB Output is correct
4 Correct 97 ms 2496 KB Output is correct
5 Correct 98 ms 2392 KB Output is correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2496 KB Output is correct
2 Correct 97 ms 2392 KB Output is correct
3 Correct 97 ms 2396 KB Output is correct
4 Correct 97 ms 2496 KB Output is correct
5 Correct 98 ms 2392 KB Output is correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2496 KB Output is correct
2 Correct 97 ms 2392 KB Output is correct
3 Correct 97 ms 2396 KB Output is correct
4 Correct 97 ms 2496 KB Output is correct
5 Correct 98 ms 2392 KB Output is correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2496 KB Output is correct
2 Correct 97 ms 2392 KB Output is correct
3 Correct 97 ms 2396 KB Output is correct
4 Correct 97 ms 2496 KB Output is correct
5 Correct 98 ms 2392 KB Output is correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -