Submission #1346144

#TimeUsernameProblemLanguageResultExecution timeMemory
1346144Faisal_SaqibMobitel (COCI14_mobitel)C++20
0 / 50
2 ms4676 KiB
#include <iostream>
#include <map>
using namespace std;
const int N=302;
int a[N][N];
map<int,int> cnt[N][N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int r,s,n;
	cin>>r>>s>>n;
	for(int i=1;i<=r;i++)
	{
		for(int j=1;j<=s;j++)
		{
			cin>>a[i][j];
		}
	}
	cnt[1][1][a[1][1]]++;
	for(int i=1;i<=r;i++)
	{
		for(int j=1;j<=s;j++)
		{
			if(i==1 and j==1)continue;
			// merge cnt[i][j-1] and cnt[i-1][j]
			for(auto [w,c]:cnt[i][j-1])
			{
				if(1ll*w*a[i][j]>=n)
				{
					cnt[i][j][n]+=c;
				}
				else
				{
					cnt[i][j][w*a[i][j]]+=c;
				}
			}
			for(auto [w,c]:cnt[i-1][j])
			{
				if(1ll*w*a[i][j]>=n)
				{
					cnt[i][j][n]+=c;
				}
				else
				{
					cnt[i][j][w*a[i][j]]+=c;
				}
			}
		}
	}
	cout<<cnt[r][s][n]<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...