# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316217 | fcmalkcin | Mobitel (COCI19_mobitel) | C++17 | 1606 ms | 23040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=1e3+50;
const ll mod =1e9+7;
const ll base=1e17;
ll dp[3][305][maxn][3];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen("GIDDY.t", "r"))
{
freopen("GIDDY.inp", "r", stdin);
freopen("GIDDY.out", "w", stdout) ;
}
memset(dp,0,sizeof (dp));
ll n, m, p;
cin>>n>>m >>p ;
dp[0][1][1][0]=1;
ll nw=sqrt(p)+2;
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
ll val;
cin>>val;
ll now=i%2;
ll pre=1-now;
for (int t=1;t<=nw;t++)
{
ll h=t*val;
if (h<nw)
{
dp[now][j][h][0]=(dp[now][j][h][0]+dp[pre][j][t][0])%mod;
dp[now][j][h][0]=(dp[now][j][h][0]+dp[now][j-1][t][0])%mod;
}
else
{dp[now][j][(p+h-1)/h][1]=(dp[now][j][(p+h-1)/h][1]+dp[pre][j][t][0])%mod;
dp[now][j][(p+h-1)/h][1]=(dp[now][j][(p+h-1)/h][1]+dp[now][j-1][t][0])%mod;
}
}
for (int t=1;t<=nw;t++)
{
dp[now][j][(t+val-1)/val][1]=(dp[now][j][(t+val-1)/val][1]+dp[pre][j][t][1])%mod;
dp[now][j][(t+val-1)/val][1]=(dp[now][j][(t+val-1)/val][1]+dp[now][j-1][t][1])%mod;
}
}
for (int j=1;j<=m;j++)
for (int t=1;t<=nw;t++)
{
dp[1-(i%2)][j][t][0]=0;
dp[1-(i%2)][j][t][1]=0;
}
}
cout <<dp[n%2][m][1][1];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |