86032024-01-23 10:04:09BenedekMartonKombináció (50)cpp17Wrong answer 36/503ms3292 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++;
                cout << k << " ";
            }
        }
        cout << endl;
        x=-1;
        for(int i=m-1; i>=0 and x==-1; i--)
        {
            if(a[i]!=n and a[i+1]-a[i]>1)
            {
                x=i;
            }
        }
        for(int i=0; i<m; i++)
        {
            if(x==i)
            {
                cout << a[i]+1 << " ";
            }
            else
            {
                cout << a[i] << " ";
            }
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base36/50
1Accepted0/03ms1876 KiB
2Wrong answer0/03ms2040 KiB
3Accepted2/23ms2164 KiB
4Accepted2/22ms2240 KiB
5Accepted2/23ms2520 KiB
6Accepted2/23ms2560 KiB
7Partially correct1/22ms2532 KiB
8Accepted2/22ms2648 KiB
9Accepted2/23ms2888 KiB
10Accepted4/43ms2872 KiB
11Partially correct2/42ms2952 KiB
12Accepted4/42ms2960 KiB
13Accepted4/42ms2952 KiB
14Accepted4/43ms3084 KiB
15Partially correct2/43ms3272 KiB
16Partially correct3/62ms3292 KiB
17Wrong answer0/62ms3288 KiB