题意很简单就是在给定的序列中找到固定个数的递增的子序列,如果子序列的总个数少于要求的个数,那么就把所有的子序列输出即可,注意每组测试用例就为有一空行。
要注意要挑出重复的子序列。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
//len:搜索的长度,tmp:记录有多少个串了
int a[1001];
int n,p,len,tmp;
bool flag;
struct node {
int num;
int pos;
};//保存符合条件的子序列
node tree[1001];
//若在产生序列的前一个数字到当前这个数字中,
//出现等于num[y]的,那么说明之前已经有序列选择了num[y],
bool find(int x,int y)
{
for(int i=x+1;i<y;i++)
if(a[i] == a[y])
return false;
return true;
}
void print(int x)
{
int i;
for(i=0;i<x-1;i++)
cout<<tree[i].num<<" ";
cout<<tree[x-1].num<<endl;
}
void dfs(int deep,int pos)
{
if(tmp>=p)
return ;
if(deep == len)
{
tmp++;
flag