#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int r,c,n,a[303][303],dp[303][303][303],all[303][303];
int f(int x,int y,int p)
{
if(p>=n)return all[x][y];
if(x==r-1&&y==c-1)return 0;
if(x>=r||y>=c)return 0;
for(int i=p;i<=n;i++)
{
if(dp[x][y][i])return 0;
}
long long ans=0;
ans+=f(x+1,y,p*a[x+1][y]);
ans%=mod;
ans+=f(x,y+1,p*a[x][y+1]);
ans%=mod;
return ans;
}
bool fuck(int x,int y,int p)
{
if(p>=n)return 0;
if(x==r-1&&y==c-1)return 1;
bool t=true;
if(x!=r-1)t=min(t,fuck(x+1,y,p*a[x+1][y]));
if(y!=c-1)t=min(t,fuck(x,y+1,p*a[x][y+1]));
return dp[x][y][p]=t;
}
int d(int x,int y)
{
if(x==r-1&&y==c-1)return all[x][y]=1;
if(x>=r||y>=c)return 0;
if(all[x][y]!=-1)return all[x][y];
long long ans=0;
ans+=d(x+1,y);
ans+=d(x,y+1);
return all[x][y]=ans;
}
int main()
{
memset(all,-1,sizeof all);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>r>>c>>n;
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)cin>>a[i][j];
}
fuck(0,0,a[0][0]);
d(0,0);
cout<<f(0,0,a[0][0]);
}
Compilation message
mobitel.cpp: In function 'bool fuck(int, int, int)':
mobitel.cpp:28:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
return dp[x][y][p]=t;
~~~~~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6006 ms |
3856 KB |
Time limit exceeded |
2 |
Execution timed out |
6099 ms |
4128 KB |
Time limit exceeded |
3 |
Execution timed out |
6016 ms |
6136 KB |
Time limit exceeded |
4 |
Execution timed out |
6087 ms |
6616 KB |
Time limit exceeded |
5 |
Runtime error |
10 ms |
1784 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
10 ms |
1908 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
9 ms |
1528 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
2793 ms |
13244 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
16 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
15 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |