#include <bits/stdc++.h>
using namespace std;
int n, m, k, t, z, a, b, d[1005][1005][25], ans;
bool u[1005][1005];
int main (){
cin >> n>> m>> k>> t>> z;
for (int i = 0;i < k;i++){
cin >> a>> b;
u[a + 1][b + 1] = 1;
}
d[1][1][0] = 1;
for (int i = 1; i <= n + 1;i++)
for (int j = 1;j <= m + 1;j++){
for (int o = 0;o <= t;o++){
if (u[i][j] && o) d[i][j][o] = (d[i][j][o] + d[i - 1][j][o - 1] + d[i][j - 1][o - 1]) % z;
if (!u[i][j]) d[i][j][o] = (d[i][j][o] + d[i - 1][j][o] + d[i][j - 1][o]) % z;
}
}
for (int i = 0;i <= t;i++)
ans = (ans + d[n + 1][m + 1][i]) % z;
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
1148 KB |
Output is correct |
5 |
Correct |
9 ms |
3960 KB |
Output is correct |
6 |
Correct |
40 ms |
27000 KB |
Output is correct |
7 |
Correct |
73 ms |
42872 KB |
Output is correct |
8 |
Correct |
154 ms |
98840 KB |
Output is correct |
9 |
Runtime error |
445 ms |
200568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
615 ms |
200468 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Execution timed out |
2090 ms |
46740 KB |
Time limit exceeded |
12 |
Execution timed out |
2093 ms |
42824 KB |
Time limit exceeded |
13 |
Execution timed out |
2029 ms |
59892 KB |
Time limit exceeded |
14 |
Execution timed out |
2023 ms |
48792 KB |
Time limit exceeded |
15 |
Execution timed out |
2005 ms |
30948 KB |
Time limit exceeded |
16 |
Execution timed out |
2045 ms |
60568 KB |
Time limit exceeded |
17 |
Execution timed out |
2097 ms |
70352 KB |
Time limit exceeded |
18 |
Execution timed out |
2017 ms |
52340 KB |
Time limit exceeded |
19 |
Execution timed out |
2051 ms |
46240 KB |
Time limit exceeded |
20 |
Execution timed out |
2035 ms |
38144 KB |
Time limit exceeded |