답안 #586603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586603 2022-06-30T12:29:34 Z blue Skyscraper (JOI16_skyscraper) C++17
20 / 100
166 ms 89096 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

using ll = long long;
using vi = vector<int>;

const ll mod = 1'000'000'007LL;

ll ad(ll a, ll b)
{
	return (a+b) % mod;
}

int main()
{
	int N, L;
	cin >> N >> L;

	vi A(N);
	for(int i = 0; i < N; i++)
		cin >> A[i];

	int DP[(1<<N)][N][1+L];
	for(int m = 0; m < (1<<N); m++)
		for(int i = 0; i < N; i++)
			for(int l = 0; l <= L; l++)
				DP[m][i][l] = 0;

	for(int i = 0; i < N; i++)
		DP[(1<<i)][i][0] = 1;

	for(int m = 0; m < (1<<N); m++)
	{
		for(int i = 0; i < N; i++)
		{
			if(!(m & (1<<i)))
				continue;

			if(m == (1<<i))
				continue;

			int m2 = m ^ (1<<i);

			for(int j = 0; j < N; j++)
			{
				if(!(m2 & (1<<j)))
					continue;

				for(int l = abs(A[i] - A[j]); l <= L; l++)
					DP[m][i][l] = ad(DP[m][i][l], DP[m2][j][l - abs(A[i] - A[j])]);
			}
		}
	}

	int res = 0;
	for(int i = 0; i < N; i++)
		for(int z = 0; z <= L; z++)
			res = ad(res, DP[(1<<N) - 1][i][z]);

	cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 9 ms 7852 KB Output is correct
6 Correct 8 ms 7080 KB Output is correct
7 Correct 2 ms 1492 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 8 ms 7508 KB Output is correct
10 Correct 2 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 12500 KB Output is correct
2 Correct 155 ms 87356 KB Output is correct
3 Correct 114 ms 41676 KB Output is correct
4 Correct 164 ms 88252 KB Output is correct
5 Correct 148 ms 89096 KB Output is correct
6 Correct 166 ms 83660 KB Output is correct
7 Correct 52 ms 27208 KB Output is correct
8 Correct 90 ms 39868 KB Output is correct
9 Correct 150 ms 65812 KB Output is correct
10 Correct 155 ms 75596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 9 ms 7852 KB Output is correct
6 Correct 8 ms 7080 KB Output is correct
7 Correct 2 ms 1492 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 8 ms 7508 KB Output is correct
10 Correct 2 ms 1236 KB Output is correct
11 Correct 25 ms 12500 KB Output is correct
12 Correct 155 ms 87356 KB Output is correct
13 Correct 114 ms 41676 KB Output is correct
14 Correct 164 ms 88252 KB Output is correct
15 Correct 148 ms 89096 KB Output is correct
16 Correct 166 ms 83660 KB Output is correct
17 Correct 52 ms 27208 KB Output is correct
18 Correct 90 ms 39868 KB Output is correct
19 Correct 150 ms 65812 KB Output is correct
20 Correct 155 ms 75596 KB Output is correct
21 Runtime error 3 ms 3668 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -