86712024-01-25 06:51:01BenedekMartonKombináció (50)cpp17Partially correct 47/503ms3880 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 << " ";
        }
    }
    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>=1 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(i==m-1)
            {
                if(a[i]!=n)
                {
                    x=i;
                }
            }
            else
            {
                if(a[i+1]-a[i]>1)
                {
                    x=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
base47/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms1916 KiB
3Accepted2/23ms2132 KiB
4Partially correct1/23ms2348 KiB
5Accepted2/22ms2436 KiB
6Accepted2/23ms2572 KiB
7Accepted2/23ms2676 KiB
8Accepted2/23ms2928 KiB
9Accepted2/23ms3016 KiB
10Accepted4/43ms3032 KiB
11Accepted4/43ms3520 KiB
12Accepted4/43ms3452 KiB
13Partially correct2/42ms3408 KiB
14Accepted4/43ms3524 KiB
15Accepted4/43ms3744 KiB
16Accepted6/63ms3748 KiB
17Accepted6/63ms3880 KiB