10062022-02-23 11:49:17rmlanKombináció (50)cpp14Wrong answer 41/502ms1904 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){
            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
base41/50
1Accepted0/02ms1792 KiB
2Accepted0/01ms1804 KiB
3Accepted2/21ms1852 KiB
4Wrong answer0/21ms1752 KiB
5Accepted2/21ms1860 KiB
6Partially correct1/21ms1860 KiB
7Accepted2/21ms1868 KiB
8Accepted2/21ms1872 KiB
9Accepted2/21ms1876 KiB
10Partially correct2/41ms1876 KiB
11Accepted4/41ms1884 KiB
12Accepted4/41ms1888 KiB
13Wrong answer0/41ms1784 KiB
14Accepted4/41ms1892 KiB
15Accepted4/41ms1904 KiB
16Accepted6/61ms1904 KiB
17Accepted6/61ms1900 KiB