#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 + 1][b + 1] = 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 |
348 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
1144 KB |
Output is correct |
5 |
Correct |
9 ms |
3576 KB |
Output is correct |
6 |
Incorrect |
39 ms |
23032 KB |
Output isn't correct |
7 |
Correct |
71 ms |
36600 KB |
Output is correct |
8 |
Incorrect |
145 ms |
82692 KB |
Output isn't correct |
9 |
Runtime error |
399 ms |
167376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
576 ms |
167224 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Execution timed out |
2102 ms |
39476 KB |
Time limit exceeded |
12 |
Execution timed out |
2049 ms |
36000 KB |
Time limit exceeded |
13 |
Execution timed out |
2011 ms |
50972 KB |
Time limit exceeded |
14 |
Execution timed out |
2023 ms |
40548 KB |
Time limit exceeded |
15 |
Execution timed out |
2070 ms |
28252 KB |
Time limit exceeded |
16 |
Execution timed out |
2032 ms |
52888 KB |
Time limit exceeded |
17 |
Execution timed out |
2058 ms |
59948 KB |
Time limit exceeded |
18 |
Execution timed out |
2009 ms |
44960 KB |
Time limit exceeded |
19 |
Execution timed out |
2071 ms |
39116 KB |
Time limit exceeded |
20 |
Execution timed out |
2093 ms |
32288 KB |
Time limit exceeded |