86732024-01-25 07:07:20BenedekMartonA sárkány feladványa (50)cpp17Wrong answer 0/5025ms4216 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>=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(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
base0/50
1Wrong answer0/03ms1876 KiB
2Wrong answer0/07ms2212 KiB
3Wrong answer0/33ms2216 KiB
4Wrong answer0/33ms2468 KiB
5Wrong answer0/33ms2652 KiB
6Wrong answer0/32ms2740 KiB
7Wrong answer0/33ms2792 KiB
8Wrong answer0/325ms3508 KiB
9Wrong answer0/36ms2940 KiB
10Wrong answer0/39ms3292 KiB
11Wrong answer0/320ms3640 KiB
12Wrong answer0/32ms3072 KiB
13Wrong answer0/49ms3340 KiB
14Wrong answer0/417ms3836 KiB
15Wrong answer0/48ms3428 KiB
16Wrong answer0/48ms3680 KiB
17Wrong answer0/423ms4216 KiB