题目连接
https://www.luogu.org/problem/show?pid=2668
只要出去顺子后,剩下的牌出的最优顺序是固定的,可以用贪心从四带2对,四带2张,三带1对,三带1张,剩下的对子和单张依次打出去,再特判一下王炸算一次出去就可以了。
然后就是对顺子进行搜索,单顺子,双顺子,三顺子一次搜索与回溯。
在搜索顺子过程中可以剪枝,如果当前出牌次数大于了ans,就不往下搜索了
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int t,n,ans,a,b;
int card[20],cnt[20];
void dfs(int x){
if (x>ans) return ;
memset(cnt,0,sizeof(cnt));