47072023-03-31 09:48:39ZsBalazsKombináció (50)cpp17Wrong answer 27/503ms2984 KiB
#include <bits/stdc++.h>
using namespace std;

int n, m;

vector<int> sorrend;

bool noveld(int i) {
  if (sorrend[i] < n) {
    sorrend[i]++;
    return true;
  }
  
  if (i <= 0) {
    return false;
  }
  
  bool siker = noveld(i-1);
  
  if (!siker) {
    return false;
  }
  
  sorrend[i] = sorrend[i-1]+1;
  
  return true;
}

bool csokk(int i) {
  if (i <= 0) {
    if (sorrend[i]-1 > 0) {
      sorrend[i]--;
      return true;
    } else {
      return false;
    }
  }
  
  if (sorrend[i]-1 > sorrend[i-1]) {
    sorrend[i]--;
    return true;
  }
  
  bool siker = csokk(i-1);
  
  if (!siker) {
    return false;
  }
  
  sorrend[i] = sorrend[i-1]+1;
  
  return true;
}

int main() {
  cin >> n >> m;
  
  vector<int> realSorrend;
  
  for (int i = 0; m > i; i++) {
    int temp;
    cin >> temp;
    
    realSorrend.push_back(temp);
  }
  
  sorrend = realSorrend;
  
  bool lehet = csokk(m-1);
  
  if (lehet) {
    for (int i = 0; m > i; i++) {
      cout << sorrend[i] << " ";
    }
    
    cout << endl;
  } else {
    for (int i = n-m+1; n+1 > i; i++) {
      cout << i << " ";      
    }
    
    cout << endl;
  }
  
  sorrend = realSorrend;
  
  lehet = noveld(m-1);
  
  if (lehet) {
    for (int i = 0; m > i; i++) {
      cout << sorrend[i] << " ";
    }
    
    cout << endl;
  } else {
    for (int i = 1; m >= i; i++) {
      cout << i << " ";      
    }
    
    cout << endl;
  }
  
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base27/50
1Accepted0/03ms1684 KiB
2Wrong answer0/03ms1928 KiB
3Accepted2/23ms2140 KiB
4Accepted2/23ms2352 KiB
5Accepted2/23ms2436 KiB
6Wrong answer0/22ms2436 KiB
7Partially correct1/22ms2440 KiB
8Partially correct1/23ms2352 KiB
9Accepted2/23ms2600 KiB
10Wrong answer0/43ms2716 KiB
11Wrong answer0/42ms2644 KiB
12Accepted4/43ms2772 KiB
13Accepted4/42ms2848 KiB
14Partially correct2/43ms2848 KiB
15Accepted4/42ms2852 KiB
16Wrong answer0/63ms2968 KiB
17Partially correct3/63ms2984 KiB