$a,b,c$ 会很大,所以直接返回 $w(20,20,20)$ 就行,不要记忆化。
by aCssen @ 2023-12-16 23:43:26
@[aCssen](/user/534296) 谢 大佬!
但还是WA + TLE了~
by Allen_Z @ 2023-12-17 11:46:34
@[aCssen](/user/534296)
```cpp
#include <bits/stdc++.h>
using namespace std;
# define LL long long
const int N = 25;
int f[N][N][N];
int w(LL a,LL b,LL c){
if(a <= 0 || b <= 0 || c <= 0) return 1;
if(a > 20 || b > 20 || c > 20) return w(20,20,20);
if(f[a][b][c]) return 0;
else if(a < b && b < c) f[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-(a,b-1,c);
else f[a][b][c] = w(a - 1,b,c) + w(a - 1,b - 1,c) + w(a - 1,b,c - 1) - w(a - 1,b - 1,c - 1);
return f[a][b][c];
}
int main(){
LL a,b,c;
while(cin >> a >> b >> c){
if(a == -1 && b == -1 && c == -1){
return 0;
}else{
cout << "w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c);
}
}
}
```
by Allen_Z @ 2023-12-17 11:49:26
如果 $f_{a,b,c}$ 更新过了应该返回 $f_{a,b,c}$ 而不是 $0$。
by aCssen @ 2023-12-17 12:43:36
@[aCssen](/user/534296) 谢大佬指教!
by Allen_Z @ 2023-12-19 22:18:50