86102024-01-23 10:29:05BenedekMartonKombináció (50)cpp17Runtime error 29/503ms3556 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[m], x=-1, k;
    for(int i=0; i<m; i++)
    {
        cin >> a[i];
    }
    if(a[0]==n-m+1)
    {
        a[0]=max(n-m, 1);
        for(int i=0; i<m; i++)
        {
            cout << a[i] << " ";
        }
        cout << endl;
        for(int i=1; i<=m; i++)
        {
            cout << i << " ";
        }
        return 15;
    }
    else if(a[m-1]==m)
    {
        for(int i=n-m+1; i<=n; i++)
        {
            cout << i << " ";
        }
        cout << endl;
        a[m-1]=min(m+1, n);
        for(int i=0; i<m; i++)
        {
            cout << a[i] << " ";
        }
    }
    else
    {
        for(int i=m-1; i>=0 and x==-1; i--)
        {
            if(a[i]-a[i-1]>1)
            {
                x=i;
            }
        }
        for(int i=0; i<m; i++)
        {
            if(i<x)
            {
                cout << a[i] << " ";
            }
            else if(i==x)
            {
                k=a[i]-1;
                cout << k << " ";
            }
            else
            {
                k=n-(m-i)+1;
                cout << k << " ";
            }
        }
        cout << endl;
        x=-1;
        for(int i=m-1; i>=0 and x==-1; i--)
        {
            if((a[i]!=n and i==m-1) or a[i+1]-a[i]>1)
            {
                x=i;
            }
        }
        for(int i=0; i<m; i++)
        {
            if(x>i)
            {
                cout << a[i] << " ";
            }
            else if(x==i)
            {
                cout << a[i]+1 << " ";
                k=a[i]+1;
            }
            else
            {
                k++;
                cout << k << " ";
            }
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base29/50
1Accepted0/03ms1880 KiB
2Accepted0/03ms2072 KiB
3Runtime error0/22ms2152 KiB
4Accepted2/23ms2284 KiB
5Accepted2/22ms2368 KiB
6Runtime error0/23ms2496 KiB
7Accepted2/23ms2744 KiB
8Runtime error0/23ms2948 KiB
9Accepted2/23ms3184 KiB
10Runtime error0/43ms3272 KiB
11Partially correct2/43ms3356 KiB
12Partially correct2/43ms3336 KiB
13Accepted4/42ms3344 KiB
14Runtime error0/43ms3340 KiB
15Accepted4/43ms3464 KiB
16Partially correct3/63ms3548 KiB
17Accepted6/63ms3556 KiB