题目:
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on.
Vadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by 222). For example, the complexity of 1 4 2 3 5 is 2 and the complexity of 1 3 5 7 6 4 2 is 111.
No one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.
题意:
n个数字(1-n)随意排列,将剩下未使用过的的数字填入空置的位置(以0表示),使得复杂性最小。
复杂性:相邻两数奇偶性不同时,复杂性+1
/**
原问题:最后一位填奇/偶时,奇偶对个数最少
子问题:前一个位置为奇/偶
边界:位置为0时,直接得出解-0
dp[当前位置(长度)][已用偶数个数][当前数奇偶性]
递推:
对于当前数
填偶数 -- dp[i][j][0] = min(dp[i-1][j-1][0], dp[i-1][j-1][1] + 1);
填奇数 -- dp[i][j][1] = min(dp[i-1][j][0] + 1, dp[i-1][j][1]);
*/
#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i=a; i<b; ++i)
using namespace std;
typedef long l