150912025-02-12 18:23:38horkaKombináció (50)cpp17Partially correct 45/501ms508 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m; cin>>m>>n;
    vector<int> v(n+1);
    for(int i=1; i<=n; i++)
        cin>>v[i];
    vector<int> kov=v;
    v.push_back(m+1);
    bool volt=0;
    for(int i=n; i>0; i--)
    {
        if(v[i]!=v[i+1]-1)
        {
            volt=1;
            kov[i]++;
            for(int j=i+1; j<=n; j++)
                kov[j]=kov[j-1]+1;
            break;
        }
    }
    if(!volt)
    {
        iota(kov.begin(),kov.end(),0);
    }
    vector<int> el=v;
    volt=0;
    for(int i=n; i>0; i--)
    {
        if(v[i]!=v[i-1]+1)
        {
            volt=1;
            el[i]--;
            for(int j=n; j>i; j--)
                el[j]=m-(n-j);
            break;
        }
    }
    if(!volt)
    {
        for(int i=1; i<=n; i++)
            el[i]=m--;
    }
    for(int i=1; i<=n; i++)
        cout<<el[i]<<" ";
    cout<<"\n";
    for(int i=1; i<=n; i++)
        cout<<kov[i]<<" ";
    cout<<"\n";
}
SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/01ms508 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms508 KiB
4Accepted2/21ms316 KiB
5Partially correct1/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Partially correct1/21ms316 KiB
9Partially correct1/21ms320 KiB
10Accepted4/41ms316 KiB
11Accepted4/41ms316 KiB
12Accepted4/41ms316 KiB
13Accepted4/41ms316 KiB
14Partially correct2/41ms316 KiB
15Accepted4/41ms316 KiB
16Accepted6/61ms316 KiB
17Accepted6/61ms316 KiB