# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316217 | 2020-10-25T17:20:32 Z | fcmalkcin | Mobitel (COCI19_mobitel) | C++17 | 1606 ms | 23040 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 22912 KB | Output is correct |
2 | Correct | 47 ms | 22912 KB | Output is correct |
3 | Correct | 156 ms | 23032 KB | Output is correct |
4 | Correct | 165 ms | 22912 KB | Output is correct |
5 | Correct | 172 ms | 22912 KB | Output is correct |
6 | Correct | 164 ms | 23032 KB | Output is correct |
7 | Correct | 85 ms | 22912 KB | Output is correct |
8 | Correct | 843 ms | 22912 KB | Output is correct |
9 | Correct | 1606 ms | 22948 KB | Output is correct |
10 | Correct | 1605 ms | 23040 KB | Output is correct |