#include <cstdio>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <functional>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#define ll long long
#define ull unsigned long long
#define pb emplace_back
#define gtc cin.get()
#define endl '\n'
using namespace std;
struct nd
{
int x,y,z;
nd(ll a,ll b,ll c)
{
x=a,y=b,z=c;
}
bool operator < (const nd &a) const
{
if(x!=a.x)
return x<a.x;
else if(y!=a.y)
return y<a.y;
else return z<a.z;
}
};
map<nd,int>m;
int dfs(ll a,ll b,ll c)
{
if(m.count(nd(a,b,c)))
return m[nd(a,b,c)];
if(a<=0 || b<=0 || c<=0)
return 1;
if(a>20 || b>20 || c>20)
return m[nd(20,20,20)]=dfs(20,20,20);
if(a<b && b<c)
return m[nd(a,b,c)]=dfs(a,b,c-1)+dfs(a,b-1,c-1)-dfs(a,b-1,c);
return m[nd(a,b,c)]=dfs(a-1,b,c)+dfs(a-1,b-1,c)+dfs(a-1,b,c-1)-dfs(a-1,b-1,c-1);
}
int main()
{
//ios::sync_with_stdio(0);
//cin.tie(0);cout.tie(0);
ll a,b,c;
while(scanf("%lld %lld %lld",&a,&b,&c))
{
if(a==-1 && b==-1 && c==-1)
break;
else
printf("w(%lld, %lld, %lld) = %d",a,b,c,dfs(a,b,c));
}
return 0;
}
如题。这个是我的代码,硬核map+结构体记忆化,本地测试没问题,下载测试点比较肉眼看亦“逐字符一致”;也尝试去掉末尾回车,还是4个wa,遂求救各位dalao。
orz