10082022-02-23 12:00:35rmlanKombináció (50)cpp14Wrong answer 44/502ms1908 KiB
#include<bits/stdc++.h>
using namespace std;

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


    if(n==m){
        for(int b:a){
            cout << b << " ";
        }
        cout << endl;
        for(int b:a){
            cout << b << " ";
        }
        return 0;
    }
    c=a;
    for(int i = m-1; i > 0; i--){
        if(c[i]-c[i-1] > 1){


            c[i]--;
            int p = n;
            for(int j = m-1; j>i; j--){
                c[j]=p;
                p--;
            }
            for(int j = 0; j < m; j++){
                cout << c[j] << " ";
            }
            cout << "\n";
            break;

        }
        if(i == 1){
            if(c[0] != 1){
                c[0]--;
                int p = n;
                for(int j = m-1; j>0; j--){
                    c[j]=p;
                    p--;
                }
                for(int j = 0; j < m; j++){
                    cout << c[j] << " ";
                }
                cout << "\n";
                break;
            }
            int p = n;
            for(int j = m-1; j >= 0; j--){
                c[j]=p;
                p--;

            }
            for(int j = 0; j < m; j++){
                cout << c[j] << " ";
            }
            cout << "\n";
        }
    }
    c=a;
    for(int i = m-2; i >= 0; i--){
        if(c[m-1] != n){
            c[m-1]++;
            for(int j = 0; j < m; j++){
                cout << c[j] << " ";
            }

            break;
        }
        if(c[i+1]-c[i] > 1){
            c[i]++;
            int p = c[i]+1;
            for(int j = i+1; j < m; j++){
                c[j]=p;
                p++;
            }
            for(int j = 0; j < m; j++){
                cout << c[j] << " ";
            }
            cout << "\n";
            break;

        }
        if(i == 0){

            for(int j = 0; j < m; j++){
                cout << j+1 << " ";
            }
            cout << "\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/02ms1744 KiB
2Accepted0/01ms1784 KiB
3Accepted2/21ms1852 KiB
4Wrong answer0/21ms1852 KiB
5Accepted2/21ms1860 KiB
6Accepted2/21ms1856 KiB
7Accepted2/21ms1868 KiB
8Accepted2/21ms1872 KiB
9Accepted2/21ms1876 KiB
10Accepted4/41ms1880 KiB
11Accepted4/41ms1884 KiB
12Accepted4/41ms1888 KiB
13Wrong answer0/41ms1788 KiB
14Accepted4/41ms1896 KiB
15Accepted4/41ms1904 KiB
16Accepted6/61ms1904 KiB
17Accepted6/61ms1908 KiB