Submission #1108774

#TimeUsernameProblemLanguageResultExecution timeMemory
1108774TsaganaEnergetic turtle (IZhO11_turtle)C++14
10 / 100
65 ms83632 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; struct row { int y[1001][21]; bool t[1001]; }; int antiloop = 0; int md; int n, m; int k, t; int a[30]; row X[1001]; map<pair<int, int>, bool> mp; void solve () { cin >> n >> m >> k >> t >> md; for (int i = 0; i < k; i++) { int x, y; cin >> x >> y; X[x].t[y] = 1; } for (int i = 0; i <= t; i++) X[0].y[0][i] = 0; X[0].y[0][0] = 1; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (X[i].t[j]) { for (int l = 1; l <= t; l++) { if (i) X[i].y[j][l] += X[i-1].y[j][l-1]; if (j) X[i].y[j][l] += X[i].y[j-1][l-1]; X[i].y[j][l] %= md; } } else { for (int l = 0; l <= t; l++) { if (i) X[i].y[j][l] += X[i-1].y[j][l]; if (j) X[i].y[j][l] += X[i].y[j-1][l]; X[i].y[j][l] %= md; } } } } int ans = 0; for (int i = 0; i <= t; i++) { ans += X[n].y[m][i]; } cout << ans; } int main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...