Submission #316217

#TimeUsernameProblemLanguageResultExecution timeMemory
316217fcmalkcinMobitel (COCI19_mobitel)C++17
130 / 130
1606 ms23040 KiB
#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)

mobitel.cpp: In function 'int main()':
mobitel.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   27 |         freopen("GIDDY.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
mobitel.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   28 |         freopen("GIDDY.out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...