#include <cstdio> using nam

#include <cstdio>
using namespace std;
const int N = 110;
bool isUse[N];
int n, t;
int a[N], b[N];
bool isSmall(){
    for (int i = 1; i <= n; ++i)
        if (a[i] != b[i]) return a[i] < b[i];
    return false;
}
bool getPermutation(int pos){
    if (pos > n){
        return isSmall();
    }
    for (int i = 1; i <= n; ++i){
        if (!isUse[i]){
            b[pos] = i; isUse[i] = true;
            if (getPermutation(pos + 1)){
                return true;
            }
            isUse[i] = false;
        }
    }
    return false;
}
void getNext(){
    for (int i = 1; i <= n; ++i){
        isUse[i] = false;
    }
    getPermutation(1);
    for (int i = 1; i <= n; ++i){
        a[i] = b[i];
    }
}
int main(){
    scanf("%d%d", &n, &t);
    for (int i = 1; i <= n; ++i){
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= t; ++i){
        getNext();
    }
    for (int i = 1; i <= n; ++i){
        printf("%d", a[i]);
        if (i == n) putchar('
'); else putchar(' ');
    }
    return 0;
}

输入1:

6 10 1 6 4 5 3 2

输出1:________

输入2:

6 200 1 5 3 4 2 6

输出2:________


答案
第1空:2 1 3 5 6 4
第2空:3 2 5 6 1 4

题目信息

题号:6685
题型:填空题
知识点:NOIP真题
难度:普通