9616 2024. 02. 23 14:38:34 TortelliniJr Kombináció (50) cpp17 Részben helyes 38/50 3ms 4284 KiB
#include <iostream>
#include <vector>
using namespace std; // c++ my beloved
int main()
{
    int n, m;
    cin >> n >> m; // this i still dont understand
    vector<int> e(m + 1), f(m + 1), g(m + 1);
    for (int i = 0; i < m; i++)
    {
        cin >> e[i]; 
    }
    f = e;
    g = e;
    int c = 0; // what does this do?
    int min = 0, max = 0, cur = 0;
    bool a = false, b = false, v = true, d = true;
    for (int i = 0; i < m; i++)
    {
        if (v && e[i] != i + 1)
        {
            v = false;
        }
        if (d && e[i] != i + 1 + n - m)
        {
            d = false;
        }
    }
    if (v) // decompilers hate this one simple trick!
    {
        for (int i = 0; i < m; i++)
        {
            cout << i + 1 + n - m;
        }
        a = true;
    }
    if (d)
    {
        for (int i = 0; i < m; i++)
        {
            f[i] = i + 1;
        }
        b = true;
    }
    bool god = false;
    bool heaven = false;
    for (int i = m - 1; i >= 0; i--)
    {
        if (e[i] < n - c && !b && !heaven)
        {
            f[i]++; // DONT ReMOVE!
            for (int u = 1; u <= m - i; u++)
            {
                f[i + u] = f[i] + u; // frankly unsure of what this does
            }
            heaven = true; // this is my code atm
        }
        if (i != 0 && e[i] - e[i- 1] > 1 && !god && !a)
        {
            g[i]--;
            for (int u = 1; u < m - i; u++)
            {
                g[i + u] = u + i + 1 + n - m;
            }
            god = true;
        }
        c++;
    }
    for (int i = 0; i < m; i++)
    {
        cout << g[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < m; i++)
    {
        cout << f[i] << " ";
    }
}
// TODO: Optimize, remove M00SE
// O(n to the power of n) time complexity
Részfeladat Összpont Teszt Verdikt Idő Memória
base 38/50
1 Elfogadva 0/0 3ms 1812 KiB
2 Elfogadva 0/0 3ms 2060 KiB
3 Részben helyes 1/2 3ms 2268 KiB
4 Részben helyes 1/2 3ms 2480 KiB
5 Részben helyes 1/2 3ms 2720 KiB
6 Részben helyes 1/2 3ms 3028 KiB
7 Elfogadva 2/2 3ms 3108 KiB
8 Részben helyes 1/2 3ms 3320 KiB
9 Részben helyes 1/2 3ms 3496 KiB
10 Részben helyes 2/4 3ms 3628 KiB
11 Elfogadva 4/4 3ms 3704 KiB
12 Elfogadva 4/4 3ms 3980 KiB
13 Részben helyes 2/4 3ms 4048 KiB
14 Részben helyes 2/4 3ms 4168 KiB
15 Elfogadva 4/4 3ms 4172 KiB
16 Elfogadva 6/6 3ms 4284 KiB
17 Elfogadva 6/6 3ms 4248 KiB