#include <bits/stdc++.h>
using namespace std;
/*long long nr(int x,int y,int x2,int y2)
{
}*/
int fr[1005][1005],din[1005][1005][21],k,t,z,n,m;
struct wow
{
int x,y;
}v[105];
long long brut()
{
int i,j;
for (i=1;i<=k;i++)
{
fr[v[i].x][v[i].y]=1;
}
din[1][1][0]=1;
for (i=1;i<=n;i++)
{
for (j=1;j<=m;j++)
{
if (i!=1||j!=1)
{
for (int r=fr[i][j];r<=k;r++)
{
din[i][j][r]=(din[i][j][r]+din[i-1][j][r-fr[i][j]]+din[i][j-1][r-fr[i][j]])%z;
}
}
}
}
long long sum=0;
for (int r=0;r<=t;r++)
{
sum=(sum+din[n][m][r])%z;
}
return sum;
}
int i;
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(0);
#ifdef HOME
ifstream cin("turtle.in");
ofstream cout("turtle.out");
#endif // HOME
cin>>n>>m>>k>>t>>z;
n++;
m++;
for (i=1;i<=k;i++)
{
cin>>v[i].x>>v[i].y;
v[i].x++;
v[i].y++;
}
cout<<brut();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
1100 KB |
Output is correct |
5 |
Correct |
6 ms |
3532 KB |
Output is correct |
6 |
Correct |
29 ms |
22920 KB |
Output is correct |
7 |
Correct |
57 ms |
36580 KB |
Output is correct |
8 |
Correct |
107 ms |
82968 KB |
Output is correct |
9 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 |
10 |
Runtime error |
5 ms |
452 KB |
Execution killed with signal 11 |
11 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 |
12 |
Runtime error |
5 ms |
332 KB |
Execution killed with signal 11 |
13 |
Runtime error |
5 ms |
388 KB |
Execution killed with signal 11 |
14 |
Runtime error |
5 ms |
460 KB |
Execution killed with signal 11 |
15 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 |
16 |
Runtime error |
5 ms |
388 KB |
Execution killed with signal 11 |
17 |
Runtime error |
5 ms |
388 KB |
Execution killed with signal 11 |
18 |
Runtime error |
5 ms |
332 KB |
Execution killed with signal 11 |
19 |
Runtime error |
5 ms |
460 KB |
Execution killed with signal 11 |
20 |
Runtime error |
5 ms |
460 KB |
Execution killed with signal 11 |