48422023-03-31 19:26:57AblablablaKombináció (50)cpp17Accepted 50/503ms3312 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> ules(m + 2, 0);
    ules[m + 1] = n;
    for(int i = 1; i <= m; i++){
        cin >> ules[i];
    }

    if(m == 1){
        if(ules[1] - 1 > 0){
            cout << ules[1] - 1 << "\n";
        } else{
            cout << n << "\n";
        }

        if(ules[1] + 1 <= n){
            cout << ules[1] + 1 << "\n";
        } else{
            cout << "1\n";
        }
    } else{
        int valtas = m;
        while(valtas > 0 && ules[valtas] - ules[valtas - 1] <= 1){
            valtas--;
        }

        //cout << valtas << "\n";
        if(valtas == 0){
            // legkisebb eset -> legnagyobbat kell kiirni
            for(int i = 1; i <= m; i++){
                cout << n - m + i << " ";
            }
        } else{
            for(int i = 1; i <= m; i++){
                if(valtas == i){
                    cout << ules[i] - 1 << " ";
                    for(int j = i + 1; j <= m; j++){
                        cout << n - m + j << " ";
                    }
                    break;
                } else{
                    cout << ules[i] << " ";
                }
            }
        }

        cout << "\n";

        if(ules[m + 1] - ules[m] >= 1){
            valtas = m;
        } else{
            valtas = m - 1;
            while(valtas > 0 && ules[valtas + 1] - ules[valtas] <= 1){
                valtas--;
            }
        }

        //cout << valtas << "\n";

        if(valtas == 0){
            // legnagyobb eset -> legkisebbet kell kiirni
            for(int i = 1; i <= m; i++){
                cout << i << " ";
            }
        } else{
            for(int i = 1; i <= m; i++){
                if(valtas == i){
                    cout << ules[i] + 1 << " ";
                    for(int j = ules[i] + 2; i < m; j++){
                        cout << j << " ";
                        i++;
                    }
                } else{
                    cout << ules[i] << " ";
                }
            }
        }

        cout << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2064 KiB
3Accepted2/23ms2140 KiB
4Accepted2/23ms2220 KiB
5Accepted2/22ms2296 KiB
6Accepted2/23ms2548 KiB
7Accepted2/22ms2632 KiB
8Accepted2/23ms2760 KiB
9Accepted2/22ms2844 KiB
10Accepted4/42ms2844 KiB
11Accepted4/43ms2968 KiB
12Accepted4/42ms2936 KiB
13Accepted4/43ms2936 KiB
14Accepted4/43ms2940 KiB
15Accepted4/43ms2936 KiB
16Accepted6/63ms3064 KiB
17Accepted6/63ms3312 KiB