# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379732 | SolarSystem | Energetic turtle (IZhO11_turtle) | C++17 | 2094 ms | 262144 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 <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <random>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m, k, t, z;
cin >> n >> m >> k >> t >> z;
map<pair<int, int>, bool> mp;
while (k--) {
int x, y;
cin >> x >> y;
mp[{x, y}] = 1;
}
long long dp[n + 1][m + 1][t + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= t; k++) {
dp[i][j][k] = 0;
}
}
}
dp[0][0][t] = 1;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= t; k++) {
if (i + 1 <= n && k >= mp[{i, j}]) {
dp[i + 1][j][k - mp[{i, j}]] += dp[i][j][k];
dp[i + 1][j][k - mp[{i, j}]] %= z;
}
if (!mp[{i, j}]) {
if (j + 1 <= m) {
dp[i][j + 1][k] += dp[i][j][k];
dp[i][j + 1][k] %= z;
}
}
}
}
}
long long ans = 0;
for (int i = 0; i <= t; i++) {
ans += dp[n][m][i];
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |