33402023-02-26 13:40:321478Kombináció (50)cpp17Partially correct 46/503ms4452 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)
        {
            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/03ms1760 KiB
2Accepted0/03ms1996 KiB
3Partially correct1/23ms2204 KiB
4Accepted2/23ms2436 KiB
5Accepted2/23ms2904 KiB
6Partially correct1/23ms3004 KiB
7Accepted2/23ms3208 KiB
8Accepted2/23ms3364 KiB
9Accepted2/23ms3492 KiB
10Partially correct2/43ms3636 KiB
11Accepted4/43ms3712 KiB
12Accepted4/43ms3952 KiB
13Accepted4/42ms3928 KiB
14Accepted4/43ms4056 KiB
15Accepted4/43ms4268 KiB
16Accepted6/63ms4232 KiB
17Accepted6/63ms4452 KiB