#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <random>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m, k, t, z;
cin >> n >> m >> k >> t >> z;
map<pair<int, int>, bool> mp;
while (k--) {
int x, y;
cin >> x >> y;
mp[{x, y}] = 1;
}
long long dp[n + 1][m + 1][t + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= t; k++) {
dp[i][j][k] = 0;
}
}
}
dp[0][0][t] = 1;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= t; k++) {
if (i + 1 <= n && k >= mp[{i, j}]) {
dp[i + 1][j][k - mp[{i, j}]] += dp[i][j][k];
dp[i + 1][j][k - mp[{i, j}]] %= z;
}
if (!mp[{i, j}]) {
if (j + 1 <= m) {
dp[i][j + 1][k] += dp[i][j][k];
dp[i][j + 1][k] %= z;
}
}
}
}
}
long long ans = 0;
for (int i = 0; i <= t; i++) {
ans += dp[n][m][i];
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
492 KB |
Output isn't correct |
4 |
Incorrect |
10 ms |
1004 KB |
Output isn't correct |
5 |
Incorrect |
174 ms |
6764 KB |
Output isn't correct |
6 |
Incorrect |
945 ms |
29804 KB |
Output isn't correct |
7 |
Execution timed out |
2094 ms |
60012 KB |
Time limit exceeded |
8 |
Execution timed out |
2059 ms |
89580 KB |
Time limit exceeded |
9 |
Runtime error |
154 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
149 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
12 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
14 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
16 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
17 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
18 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
19 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
20 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |