48082023-03-31 12:45:32AblablablaKombináció (50)cpp17Partially correct 44/503ms3376 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";

        valtas = m;
        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
base44/50
1Accepted0/03ms1808 KiB
2Accepted0/03ms2064 KiB
3Accepted2/22ms2140 KiB
4Accepted2/23ms2220 KiB
5Accepted2/23ms2424 KiB
6Accepted2/22ms2512 KiB
7Partially correct1/23ms2640 KiB
8Accepted2/23ms2756 KiB
9Accepted2/23ms2884 KiB
10Accepted4/43ms3156 KiB
11Accepted4/42ms3104 KiB
12Accepted4/43ms3168 KiB
13Accepted4/42ms3280 KiB
14Accepted4/43ms3252 KiB
15Partially correct2/42ms3376 KiB
16Accepted6/62ms3268 KiB
17Partially correct3/63ms3236 KiB