답안 #1039349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039349 2024-07-30T18:43:37 Z iliaaaaa Skyscraper (JOI16_skyscraper) C++14
15 / 100
1 ms 856 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()
#define pb push_back
#define int long long

const int N = 100 + 7, M = 1000 + 7, P = 1e9 + 7;
int n, l, a[N], dp[N][N][M][3];

int32_t main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> l;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	a[n + 1] = 1e4;
	dp[0][0][0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++)
			for (int k = 0; k <= l; k++)
				for (int m = 0; m <= 2; m++) {
					int t = 2 * j * (a[i + 1] - a[i]) - m * (a[i + 1] - a[i]);
					if (t > k || i + j + 1 - m > n)
						continue;
					// j - 1 => j
					dp[i][j][k][m] = (dp[i][j][k][m] + dp[i - 1][j - 1][k - t][m]) % P;
					if (m)
						dp[i][j][k][m] = (dp[i][j][k][m] + (2 - (m - 1)) * dp[i - 1][j - 1][k - t][m - 1]) % P;
					// j => j adi
					dp[i][j][k][m] = (dp[i][j][k][m] + 1LL * (2 * (j - m) + m) * dp[i - 1][j][k - t][m] % P) % P;
					// j => j gooshe
					if (m == 1)
						dp[i][j][k][m] = (dp[i][j][k][m] + 2 * j * dp[i - 1][j][k - t][0] % P) % P;
					else if (m == 2) {
						if (i == n) {
							if (j == 1)
								dp[i][j][k][m] = (dp[i][j][k][m] + dp[i - 1][j][k - t][m - 1]) % P;
						}
						else
							dp[i][j][k][m] = (dp[i][j][k][m] + (j - 1) * dp[i - 1][j][k - t][m - 1] % P) % P;
					}
					// j + 1 => j
					if (m == 2) {
						if (i == n) {
							if (j == 1)
								dp[i][j][k][m] = (dp[i][j][k][m] + dp[i - 1][j + 1][k - t][m]) % P;
						}
						else
							dp[i][j][k][m] = (dp[i][j][k][m] + 1LL * j * (j - 1) % P * dp[i - 1][j + 1][k - t][m] % P) % P;
					}
					else if (m == 1)
						dp[i][j][k][m] = (dp[i][j][k][m] + 1LL * j * j % P * dp[i - 1][j + 1][k - t][m] % P) % P;
					else
						dp[i][j][k][m] = (dp[i][j][k][m] + 1LL * j * (j + 1) % P * dp[i - 1][j + 1][k - t][m] % P) % P;
					if (dp[i][j][k][m] < 0)
						assert(0);
				}
	int ans = 0;
	for (int i = 0; i <= l; i++)
		ans = (ans + dp[n][1][i][2]) % P;
	cout << ans << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -