# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88665 | turbat | Energetic turtle (IZhO11_turtle) | C++14 | 55 ms | 604 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, ans, d[5][10005][22];
bool u[5005][5005];
int main (){
cin >> n>> m>> k>> t>> z;
if (n > 1000 && m > 1000) return 0;
while(k--){
cin >> a>> b;
u[a + 1][b + 1] = 1;
}
d[2][1][0] = 1;
for (int i = 1; i <= n + 1;i++){
for (int j = 1;j <= m + 1;j++)
for (int o = 0;o <= t;o++){
if (u[i][j] && o) d[2][j][o] = (d[2][j][o] + d[1][j][o - 1] + d[2][j - 1][o - 1]) % z;
if (!u[i][j]) d[2][j][o] = (d[2][j][o] + d[1][j][o] + d[2][j - 1][o]) % z;
}
for (int l = 1;l <= 2;l++)
for (int j = 1;j <= m + 1;j++)
for (int o = 0;o <= t;o++)
d[l][j][o] = d[l + 1][j][o];
}
for (int i = 0;i <= t;i++)
ans = (ans + d[1][m + 1][i]) % z;
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |