47062023-03-31 09:48:21ZsBalazsLádapakolás raktárban (50)cpp17Wrong answer 0/50120ms63236 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
base0/50
1Wrong answer0/03ms1812 KiB
2Wrong answer0/03ms2016 KiB
3Wrong answer0/23ms2220 KiB
4Wrong answer0/23ms2428 KiB
5Wrong answer0/22ms2512 KiB
6Wrong answer0/23ms2756 KiB
7Wrong answer0/22ms2752 KiB
8Wrong answer0/23ms2880 KiB
9Wrong answer0/33ms2752 KiB
10Wrong answer0/23ms2856 KiB
11Wrong answer0/23ms2936 KiB
12Wrong answer0/23ms3072 KiB
13Wrong answer0/36ms3680 KiB
14Wrong answer0/33ms3408 KiB
15Wrong answer0/335ms10860 KiB
16Wrong answer0/24ms3840 KiB
17Runtime error0/379ms63236 KiB
18Runtime error0/3120ms62988 KiB
19Runtime error0/3103ms62992 KiB
20Runtime error0/3104ms62752 KiB
21Runtime error0/3103ms62724 KiB
22Runtime error0/3107ms62716 KiB