#include <bits/stdc++.h>
#define pb push_back
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())
#define int long long
typedef long long ll;
using namespace std;
const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;
int n, m, a[2890002], d[2890002][21], z, k, t, x, y, sum;
inline int cv(int X, int Y) {
return (X * (m + 1ll)) + Y;
}
main () {
//freopen(fname".in", "r", stdin);
//freopen(fname".out", "w", stdout);
scanf("%lld%lld%lld%lld%lld", &n, &m, &k, &t, &z);
for (int i = 1; i <= k; ++i) {
scanf("%d%d", &x, &y);
a[cv(x, y)] = 1;
}
d[cv(0, 0)][0] = 1;
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= m; ++j) {
if (i == 0 && j == 0) continue;
if (a[cv(i, j)] == 1) {
for (int q = 1; q <= t; ++q) {
if (i != 0)
d[cv(i, j)][q] += d[cv(i - 1, j)][q - 1];
if (j != 0)
d[cv(i, j)][q] += d[cv(i, j - 1)][q - 1];
d[cv(i, j)][q] %= z;
}
}else {
for (int q = 0; q <= t; ++q) {
if (i != 0)
d[cv(i, j)][q] += d[cv(i - 1, j)][q];
if (j != 0)
d[cv(i, j)][q] += d[cv(i, j - 1)][q];
d[cv(i, j)][q] %= z;
}
}
}
}
for (int i = 0; i <= t; ++i) {
sum += d[cv(n, m)][i];
sum %= z;
}
printf("%lld", sum);
return 0;
}
Compilation message
turtle.cpp:28:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
turtle.cpp: In function 'int main()':
turtle.cpp:33:24: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
scanf("%d%d", &x, &y);
~~ ^
turtle.cpp:33:24: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
turtle.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%lld%lld%lld", &n, &m, &k, &t, &z);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
turtle.cpp:33:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &x, &y);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
632 KB |
Output is correct |
4 |
Correct |
4 ms |
1016 KB |
Output is correct |
5 |
Correct |
1 ms |
5112 KB |
Output is correct |
6 |
Correct |
74 ms |
41600 KB |
Output is correct |
7 |
Correct |
157 ms |
66368 KB |
Output is correct |
8 |
Correct |
296 ms |
165088 KB |
Output is correct |
9 |
Runtime error |
27 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
29 ms |
408 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
27 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
27 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
27 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
27 ms |
408 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
27 ms |
412 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
27 ms |
468 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
27 ms |
476 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
26 ms |
448 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
27 ms |
472 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
28 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |