#include <bits/stdc++.h>
using namespace std;
int n, m, k, t, z, a, b, d[1001][1001][21], ans;
bool u[1002][1002];
int main (){
cin >> n>> m>> k>> t>> z;
for (int i = 0;i < k;i++){
cin >> a>> b;
u[a][b] = 1;
}
d[0][0][0] = 1;
for (int i = 0; i <= n;i++)
for (int j = 0;j <= m;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][m][i]) % z;
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
7 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
1148 KB |
Output is correct |
5 |
Correct |
8 ms |
3576 KB |
Output is correct |
6 |
Correct |
36 ms |
23056 KB |
Output is correct |
7 |
Correct |
65 ms |
36604 KB |
Output is correct |
8 |
Incorrect |
133 ms |
82680 KB |
Output isn't correct |
9 |
Runtime error |
397 ms |
167292 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
578 ms |
167384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Execution timed out |
2045 ms |
38132 KB |
Time limit exceeded |
12 |
Execution timed out |
2080 ms |
36116 KB |
Time limit exceeded |
13 |
Execution timed out |
2068 ms |
52872 KB |
Time limit exceeded |
14 |
Execution timed out |
2077 ms |
42040 KB |
Time limit exceeded |
15 |
Execution timed out |
2073 ms |
28108 KB |
Time limit exceeded |
16 |
Execution timed out |
2005 ms |
51312 KB |
Time limit exceeded |
17 |
Execution timed out |
2070 ms |
59824 KB |
Time limit exceeded |
18 |
Execution timed out |
2009 ms |
44852 KB |
Time limit exceeded |
19 |
Execution timed out |
2098 ms |
39556 KB |
Time limit exceeded |
20 |
Execution timed out |
2079 ms |
32140 KB |
Time limit exceeded |