# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338091 | juggernaut | Energetic turtle (IZhO11_turtle) | C++14 | 2094 ms | 262148 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;
typedef long long ll;
ll dp[2005][2005][21],mod,a[2005][2005];
int n,m,k,t;
int main(){
scanf("%d%d%d%d%lld",&n,&m,&k,&t,&mod);
while(k--){
int x,y;
scanf("%d%d",&x,&y);
a[x+1][y+1]=1;
}
dp[1][0][0]=1;
for(int i=1;i<=n+1;i++)
for(int j=1;j<=m+1;j++)
if(a[i][j])for(int l=1;l<=t;l++)dp[i][j][l]=(dp[i-1][j][l-1]+dp[i][j-1][l-1])%mod;
else for(int l=0;l<=t;l++)dp[i][j][l]=(dp[i-1][j][l]+dp[i][j-1][l])%mod;
ll res=0;
for(int i=0;i<=t;i++)res=(res+dp[n+1][m+1][i])%mod;
printf("%lld",res);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |