답안 #1108773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108773 2024-11-05T03:46:53 Z Tsagana 최솟값 배열 (IZhO11_hyper) C++14
0 / 100
2000 ms 336 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;
	}
	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;}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2047 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -