# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523355 | Farhan_HY | Cheerleaders (info1cup20_cheerleaders) | C++14 | 2090 ms | 1964 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.
#include <bits/stdc++.h>
#define int long long
#define float double
#define pb push_back
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
using namespace std;
const int inf = 8e18;
const int N = 1e6 + 6;
const int M = 1e3 + 3;
const int mod = 1e9 + 7;
const float pi = atan(1) * 4;
int a[N];
int n, m;
vector<int> ans;
int Cnt_Min = inf;
vector<int> v;
bool check()
{
int cnt = 0;
for(int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; j++)
cnt += (a[j] > a[i]);
}
if (cnt < Cnt_Min)
ans = v, Cnt_Min = cnt;
}
void bt(int i, int sum)
{
if (sum >= 8)
{
if (sum == 8)
check();
return;
}
v.pb(2);
bt(i + 1, sum + 2);
v.pop_back();
v.pb(1);
bt(i + 1, sum + 1);
v.pop_back();
}
main()
{
cin >> n;
n = (1ll << n);
for(int i = 0; i < n; i++)
cin >> a[i];
bt(0, 0);
cout << 8 << '\n';
for(auto x: ans)
cout << x;
}
//3
//2 3 7 6 1 4 5 0
//2 7 1 5 3 6 5 0
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... |