Submission #88671

#TimeUsernameProblemLanguageResultExecution timeMemory
88671BadralEnergetic turtle (IZhO11_turtle)C++17
5 / 100
351 ms165752 KiB
#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 timeMemoryGrader output
Fetching results...