Submission #159898

# Submission time Handle Problem Language Result Execution time Memory
159898 2019-10-25T10:03:38 Z mdn2002 Mobitel (COCI19_mobitel) C++14
0 / 130
17 ms 2552 KB
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
long long r,c,n,a[303][303],dp[303][303],all[303][303];
int f(int x,int y,long long p)
{
    //if(p>=n)return all[x][y];
    if(x==r-1&&y==c-1)return 1;
    if(x>=r||y>=c)return 0;
    if(dp[x][y]*p<n)return 0;
    long long ans=0;
    ans+=f(x+1,y,p*a[x][y]);
    ans%=mod;
    ans+=f(x,y+1,p*a[x][y]);
    ans%=mod;
    return ans;
}
int fuck(int x,int y)
{
    if(x==r-1&&y==c-1)return dp[x][y]=a[x][y];
    if(dp[x][y]!=-1)return dp[x][y];
    long long t=0;
    if(x!=r-1)t=max(t,fuck(x+1,y)*a[x][y]);
    if(t>=n)t=n;
    if(y!=c-1)t=max(t,fuck(x,y+1)*a[x][y]);
    if(t>=n)t=n;
    return dp[x][y]=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);
    memset(dp,-1,sizeof dp);
    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++)scanf("%d",&a[i][j]);
    }
    d(0,0);
    fuck(0,0);
    cout<<f(0,0,a[0][0]);
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:49:48: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         for(int j=0;j<c;j++)scanf("%d",&a[i][j]);
                                        ~~~~~~~~^
mobitel.cpp:49:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int j=0;j<c;j++)scanf("%d",&a[i][j]);
                             ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2424 KB Output isn't correct
2 Incorrect 16 ms 2552 KB Output isn't correct
3 Incorrect 7 ms 1884 KB Output isn't correct
4 Incorrect 7 ms 1912 KB Output isn't correct
5 Incorrect 7 ms 1912 KB Output isn't correct
6 Incorrect 7 ms 1912 KB Output isn't correct
7 Incorrect 6 ms 1912 KB Output isn't correct
8 Incorrect 11 ms 2296 KB Output isn't correct
9 Incorrect 16 ms 2428 KB Output isn't correct
10 Incorrect 17 ms 2424 KB Output isn't correct