Submission #100374

# Submission time Handle Problem Language Result Execution time Memory
100374 2019-03-10T16:19:02 Z Runtime_error_ Mobitel (COCI19_mobitel) C++14
0 / 130
90 ms 66560 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=3e2+9,mod=1e9+7;

ll a[inf][inf],n,m,k,dp[inf][inf][inf];

ll solve(ll i,ll j,ll sum){

    if( i>n || j>m)
        return 0;

    if(i==n && j==m)
        return (sum>=k);

    ll &ret=dp[i][j][sum];
    if(ret!=-1)
        return ret;

        ret=0;

        ret=((long long )ret+solve(i+1,j,min(k,sum*a[i+1][j]) )  )%mod;

        ret=((long long )ret+solve(i,j+1,min(sum*a[i][j+1],k)))%mod;
        return ret;
}

int main(){

    cin>>n>>m>>k;
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=m;j++)
            cin>>a[i][j];

    memset(dp,-1,sizeof(dp));

    cout<<solve(1,1,min(a[1][1],k))<<endl;
}

Compilation message

mobitel.cpp: In function 'long long int solve(long long int, long long int, long long int)':
mobitel.cpp:17:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(ret!=-1)
     ^~
mobitel.cpp:20:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         ret=0;
         ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 78 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 90 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 62 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 63 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 63 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 61 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 75 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 87 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 73 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 79 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)