93892024-02-21 11:52:15Vkrisztian01Kombináció (50)cpp17Partially correct 46/503ms3904 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
base46/50
1Accepted0/03ms1876 KiB
2Accepted0/03ms2120 KiB
3Partially correct1/23ms2328 KiB
4Accepted2/23ms2492 KiB
5Accepted2/23ms2744 KiB
6Accepted2/23ms2956 KiB
7Accepted2/23ms3172 KiB
8Partially correct1/23ms3284 KiB
9Accepted2/23ms3276 KiB
10Accepted4/43ms3360 KiB
11Accepted4/43ms3488 KiB
12Accepted4/43ms3860 KiB
13Accepted4/43ms3904 KiB
14Partially correct2/43ms3792 KiB
15Accepted4/43ms3700 KiB
16Accepted6/63ms3704 KiB
17Accepted6/63ms3832 KiB