8642022-01-21 19:52:35Valaki2Kombináció (50)cpp14Wrong answer 46/502ms1980 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n, m;
vector<bool> is;
vector<bool> ans;

void solve() {
    cin >> n >> m;
    is.assign(1 + n, false);
    for(int i = 0; i < m; i++) {
        int x;
        cin >> x;
        is[x] = true;
    }
    ans.assign(1 + n, false);
    bool ok = false;
    for(int i = 1; i <= m; i++) {
        if(!is[i]) {
            ok = true;
        }
    }
    if(!ok) {
        for(int i = n; i >= n - m + 1; i--) {
            ans[i] = true;
        }
    } else {
        for(int i = n; i >= 1; i--) {
            if(is[i] && !is[i - 1]) {
                ans = is;
                ans[i] = false;
                ans[i - 1] = true;
                break;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        if(ans[i]) {
            cout << i << " ";
        }
    }
    cout << "\n";
    ans.assign(1 + n, false);
    ok = false;
    for(int i = n; i >= n - m + 1; i--) {
        if(!is[i]) {
            ok = true;
        }
    }
    if(!ok) {
        for(int i = 1; i <= m; i++) {
            ans[i] = true;
        }
    } else {
        for(int i = n; i >= 1; i--) {
            if(!is[i] && is[i - 1]) {
                ans = is;
                ans[i] = true;
                ans[i - 1] = false;
                break;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        if(ans[i]) {
            cout << i << " ";
        }
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/02ms1876 KiB
2Wrong answer0/01ms1860 KiB
3Accepted2/21ms1916 KiB
4Accepted2/21ms1928 KiB
5Accepted2/21ms1932 KiB
6Accepted2/21ms1936 KiB
7Partially correct1/21ms1944 KiB
8Accepted2/21ms1944 KiB
9Accepted2/21ms1944 KiB
10Accepted4/41ms1956 KiB
11Accepted4/41ms1952 KiB
12Accepted4/41ms1956 KiB
13Accepted4/41ms1964 KiB
14Accepted4/41ms1968 KiB
15Accepted4/41ms1972 KiB
16Accepted6/61ms1976 KiB
17Partially correct3/61ms1980 KiB