# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88671 | Badral | Energetic turtle (IZhO11_turtle) | C++17 | 351 ms | 165752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
using namespace std;
ll n, m, a[maxn][maxn], d[maxn][maxn][21], z, k, t, sum;
int main () {
cin>>n >>m >>k >>t >>z;
for (int i = 1; i <= k; ++i) {
int x, y;
cin >>x >>y;
a[x][y] = 1;
}
d[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[i][j] == 1) {
for(int q = 1; q <= t; q++) {
if (i > 0)
d[i][j][q] += d[i-1][j][q - 1];
if (j > 0)
d[i][j][q] += d[i][j][q - 1];
d[i][j][q] %= z;
}
}
else {
for (int q = 0; q <= t; ++q) {
if (i > 0)
d[i][j][q] += d[i - 1][j][q];
if (j > 0)
d[i][j][q] += d[i][j - 1][q];
d[i][j][q] %= z;
}
}
}
}
for (int i = 0; i <= t; ++i) {
sum += d[n][m][i];
sum %= z;
}
cout<<sum;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |