93902024-02-21 11:53:09Vkrisztian01Kombináció (50)cpp17Partially correct 44/503ms4120 KiB
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int n,m;
vector<int>nums;
vector<int>seged;

int main()
{
    cin>>n>>m;
    nums.resize(m);
    for(int i=0;i<m;i++) cin>>nums[i];
    if(m==1)
    {
        if(nums[0]==1) cout<<n<<endl<<2;
        if(nums[0]==n) cout<<n-1<<endl<<1;
        if(nums[0]<n && 1<nums[0]) cout<<nums[0]-1<<endl<<nums[0]+1;
        return 0;
    }

    if(nums[0]==n-m+1)
    {
        --nums[0];
        for(auto x:nums) cout<<x<<" ";
        cout<<endl;
        for(int i=1;i<=m;i++) cout<<i<<" ";
        return 0;
    }

   /* if(nums[m-1]==m)
    {
        for(int i=m;i>=1;i--) cout<<n-i+1<<" ";
        cout<<endl;
        ++nums[m-1];
        for(auto x:nums) cout<<x<<" ";
        return 0;
    }*/
    for(int i=m-1;i>=0;i--)
    {
        if(i!=0 && nums[i-1]==nums[i]-1) continue;
        for(int j=0;j<i;j++) cout<<nums[j]<<" ";
        cout<<nums[i]-1<<" ";
        for(int j=m-i-1;j>=1;j--) cout<<n-j+1<<" ";
        cout<<endl;
        break;
    }
    for(int i=m-1;i>=0;i--)
    {
        if(nums[i]==n -(m-i-1)) continue;
        for(int j=0;j<i;j++) cout<<nums[j]<<" ";
        for(int j=1;i+j<=m;j++) cout<<nums[i]+j<<" ";
        break;

    }


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2064 KiB
3Partially correct1/23ms2280 KiB
4Accepted2/23ms2492 KiB
5Partially correct1/23ms2704 KiB
6Accepted2/23ms2932 KiB
7Accepted2/23ms3060 KiB
8Partially correct1/23ms3096 KiB
9Partially correct1/23ms3068 KiB
10Accepted4/43ms3196 KiB
11Accepted4/43ms3352 KiB
12Accepted4/43ms3560 KiB
13Accepted4/43ms3628 KiB
14Partially correct2/43ms3756 KiB
15Accepted4/43ms4008 KiB
16Accepted6/63ms4120 KiB
17Accepted6/62ms4092 KiB