这题嘛,我们可以首先考虑枚举一共n*(n-1)/2次比赛的结果,然后判断一下就好了
其实有一点是显然的,分数序列的顺序不影响答案
所以我们用最小表示法来表示分数序列,然后记忆化搜索一下就好了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int p=(1e9)+7;
map<ll,ll>mp;
int n;
struct state{
int a[11];
ll hash(){
ll ans=0;
for(int i=0;i<=n;i++)ans=ans*28+a[i];
return ans;
}
void minexp(){
sort(a+a[0],a+n+1);
}
}st,ed;
ll dfs(int i,state now){
if(now.a[0]==n)return mp[now.hash()]=-1;
if(now.a[now.a[0]]>3*(n-i+1))return -1;
if(i>n){
now.a[0]++;
now.minexp();
if(mp[now.hash()])return mp[now.hash()];
return dfs(now.a