Submission #1108776

# Submission time Handle Problem Language Result Execution time Memory
1108776 2024-11-05T03:49:35 Z Tsagana Energetic turtle (IZhO11_turtle) C++14
40 / 100
62 ms 83528 KB
#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;
	}
	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];
		ans %= md;
	}
	cout << ans;
}
int main() {IOS solve(); return 0;}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 2 ms 8784 KB Output is correct
5 Correct 4 ms 15184 KB Output is correct
6 Correct 14 ms 30544 KB Output is correct
7 Correct 27 ms 49480 KB Output is correct
8 Correct 62 ms 83528 KB Output is correct
9 Runtime error 5 ms 592 KB Execution killed with signal 11
10 Runtime error 5 ms 592 KB Execution killed with signal 11
11 Runtime error 5 ms 592 KB Execution killed with signal 11
12 Runtime error 6 ms 592 KB Execution killed with signal 11
13 Runtime error 5 ms 592 KB Execution killed with signal 11
14 Runtime error 5 ms 592 KB Execution killed with signal 11
15 Runtime error 5 ms 592 KB Execution killed with signal 11
16 Runtime error 5 ms 536 KB Execution killed with signal 11
17 Runtime error 5 ms 532 KB Execution killed with signal 11
18 Runtime error 5 ms 592 KB Execution killed with signal 11
19 Runtime error 5 ms 592 KB Execution killed with signal 11
20 Runtime error 5 ms 604 KB Execution killed with signal 11