# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88615 | turbat | Energetic turtle (IZhO11_turtle) | C++14 | 2098 ms | 167384 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>
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][b] = 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |