33412023-02-26 13:41:291478Kombináció (50)cpp17Partially correct 46/503ms3476 KiB
#include <bits/stdc++.h>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int MAX_N = 101;
int n;
int k;
vector<int> a(MAX_N);
vector<int> temp;

void kiir()
{
    for (int i = 1; i <= n; i++)
    {
        if (temp[i])
        {
            cout << i << " ";
        }
        // cout << temp[i] << " ";
    }
    cout << '\n';
}

int main()
{
    fast_cin();
    // ifstream cin("in.txt");

    cin >> n;
    cin >> k;

    for (int i = 1; i <= k; i++)
    {
        int b;
        cin >> b;
        a[b] = 1;
    }

    temp.assign(all(a));
    int i = n;
    int one_db = 0;

    while (i >= 2 && (temp[i] != 1 || temp[i - 1] != 0))
    {
        if (temp[i] == 1)
        {
            if (i == 2 && temp[i - 1] == 1)
            {
                one_db++;
            }
            temp[i] = 0;
            one_db++;
        }
        i--;
    }
    swap(temp[i], temp[i - 1]);
    for (int j = n; j >= n - one_db + 1; j--)
    {
        temp[j] = 1;
    }

    kiir();

    temp.assign(all(a));

    i = n;
    one_db = 0;
    while (i >= 2 && (temp[i] != 0 || temp[i - 1] != 1))
    {
        if (temp[i] == 1)
        {
            if (i == 2 && temp[i - 1] == 1)
            {
                one_db++;
            }
            temp[i] = 0;
            one_db++;
        }
        i--;
    }

    temp[i - 1] = 0;
    for (int j = i; j <= i + one_db; j++)
    {
        temp[j] = 1;
    }
    kiir();

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms1892 KiB
2Accepted0/03ms2120 KiB
3Partially correct1/22ms2304 KiB
4Accepted2/23ms2396 KiB
5Accepted2/23ms2624 KiB
6Partially correct1/23ms2852 KiB
7Accepted2/23ms2932 KiB
8Accepted2/23ms3048 KiB
9Accepted2/23ms3128 KiB
10Partially correct2/42ms3116 KiB
11Accepted4/42ms3116 KiB
12Accepted4/42ms3216 KiB
13Accepted4/42ms3112 KiB
14Accepted4/43ms3252 KiB
15Accepted4/42ms3476 KiB
16Accepted6/62ms3328 KiB
17Accepted6/62ms3328 KiB