求助,全RE!!!!!!

P1464 Function

@[windowswu](/user/320656) 模拟一下这组数据: ```plain 100000 100000 100000 -1 -1 -1 ```
by andyli @ 2020-02-19 11:45:36



by 屑稻香 @ 2020-02-19 11:47:48


100000 100000 100000 -------------------------------- Process exited after 13.91 seconds with return value 3221225477 请按任意键继续. . .
by 屑稻香 @ 2020-02-19 11:48:14


@[windowswu](/user/320656) `else if(vis[a][b][c]!=0)return vis[a][b][c];` 考虑放到后面
by andyli @ 2020-02-19 11:51:56


@[windowswu](/user/320656) 另外a>20或b>20或c>20时是返回w(20,20,20)而不是w(a,b,c) 这样会引起无限递归
by andyli @ 2020-02-19 11:52:38


4个MLE,1个TLE
by 屑稻香 @ 2020-02-19 11:54:48


改了一下,全TLE
by 屑稻香 @ 2020-02-19 11:56:25


```cpp #include<iostream> #include<string> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; long long vis[25][25][25]; long long w(long long a,long long b,long long c){ if(a<=0||b<=0||c<=0)return 1; else if(a>20||b>20||c>20)vis[a][b][c]=w(20,20,20); else if(a<b&&b<c)vis[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); else if(vis[a][b][c]!=0)return vis[a][b][c]; else vis[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 vis[a][b][c]; } int main(){ long long a,b,c; memset(vis,0,sizeof(vis)); while(cin>>a>>b>>c&&(a!=-1||b!=-1||c!=-1))cout<<"w("<<a<<", "<<b<<", "<<c<<")="<<w(a,b,c)<<endl; return 0; } ```
by 屑稻香 @ 2020-02-19 12:01:48


|