#include<bits/stdc++.h>
#define maxn 1005
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;
int ans;
bool a[2000002];
int b[2000002][25];
int n, m, k1, t, z;
inline int lol(int X, int Y) {
return (X * (m + 1ll)) + Y;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >>n >>m >>k1 >>t >>z;
while(k1--) {
int x, y;
cin >>x >>y;
a[lol(x, y)] = 1;
}
b[lol(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[lol(i, j)] == 1) {
for(int o = 1; o <= t; o++) {
if(i != 0)
b[lol(i, j)][o] += b[lol(i-1, j)][o - 1];
if(j != 0)
b[lol(i, j)][o] += b[lol(i, j-1)][o - 1];
b[lol(i, j)][o] %= z;
}
}
else {
for(int o = 0; o <= t; o++) {
if(i != 0)
b[lol(i, j)][o] += b[lol(i - 1, j)][o];
if(j != 0)
b[lol(i, j)][o] += b[lol(i, j - 1)][o];
b[lol(i, j)][o] %= z;
}
}
}
}
for(int i = 0; i <= 20; i++) ans += b[lol(n, m)][i], ans %= z;
cout<<ans%z;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
8 ms |
3064 KB |
Output is correct |
6 |
Correct |
39 ms |
24880 KB |
Output is correct |
7 |
Correct |
72 ms |
39676 KB |
Output is correct |
8 |
Correct |
149 ms |
98372 KB |
Output is correct |
9 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
11 ms |
548 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
12 ms |
432 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
12 ms |
508 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
13 ms |
420 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
12 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
11 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
13 ms |
552 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |