当前位置:网站首页>HDU 6778 car (group enumeration -- > shape pressure DP)
HDU 6778 car (group enumeration -- > shape pressure DP)
2022-06-29 10:10:00 【It's mally!】
HDU 6778 Car ( Group enumeration –> Pressure dp)
notes :
This article first analyzes tle I really want to dfs Ideas , Look at the transition dp
subject :

wa spot :
The title says 2 The license plates may be the same , But a car with the same license plate cannot be counted as 1 car , Is still 2 car .
Topic meaning conversion :
Topic meaning conversion :
Yes 10 A valuable item , Divide into 5 Group , Make this 5 The minimum and maximum values in the group , among 10 The value of an item can be 0, The number of each group can be 0.
analysis :
< One > Full Permutation 1
Because the number of each group is uncertain , It is not easy to enumerate each group .
Blog portal , This blog uses group enumeration , First of all, the provisions of article i The number of items in the group will certainly be greater than the number of i-1 Group , So we can have A definite number of group assignments , Then select the specific device
void distrubit1_dfs(){}
...
void distrubit7_dfs(){}
void main()
{
distrubit1_dfs();
distrubit2_dfs();
distrubit3_dfs();
distrubit4_dfs();
distrubit5_dfs();
distrubit6_dfs();
distrubit7_dfs();
}
< Two > Full Permutation 2
Enumerate this 10 Items ,10 There are... Items 5 A choice , 5 10 5^{10} 510 In this case , And in this case, there is no way to reduce the expenses , Meeting t, It is written in the following way ( I use 10 A cycle has been tried , It will be tle)
void dfs(int car_id)
{
if(car_id==10)
{
int now=day_sum[1];
for(int day=1;day<=5;++day) now=min(now,day_sum[day]);
ans=max(now,ans);
return;
}
for(int day=1;day<=5;++day)
{
day_sum[day]+=car[car_id];
dfs(car_id+1); // Can't prune
day_sum[day]-=car[car_id];
}
}
< 3、 ... and > state dp
What changes over time is the state , It means that the state of each moment is enumerable
Because only one item of each kind can be taken , Then the state is determined by whether the object is taken . And the change of time is day An increase in .
That is to say, the discussion listed above is the discussion of No 1,2,k Groups are objects , And change state dp The discussion is The first 1 To the first k Group time , Which objects have been assigned .
#include "iostream"
#include "algorithm"
#include "cstring"
#include "vector"
using namespace std;
const int DAY=6;
const int NUM=1<<10+2;
int car[20];
int n,ans;
int dp[DAY][NUM]; // The first day Group The transition quantity is .. The minimum amount of time
void StatusDp()
{
memset(dp,-1,sizeof(dp));
dp[0][0]=0x3f3f3f3f;
for(int day=1;day<=5;++day)
for(int last=0;last<(1<<10);++last)
{
if(dp[day-1][last]==-1)continue;
for(int wantdo=0;wantdo<(1<<10);++wantdo)
{
if(last&wantdo)continue;
int now=0;
for(int k=0;k<10;++k)
{
if( (wantdo>>k) &1)now+=car[k];
}
dp[day][last|wantdo]=max( dp[day][last|wantdo], min(dp[day-1][last],now ) );
}
}
}
int main()
{
// freopen("in.text","r",stdin);
int cas;
scanf("%d",&cas);
while (cas--) {
memset(car, 0, sizeof(car));
scanf("%d", &n);
for(int tem,i=1;i<=n;++i)
{
scanf("%d",&tem);++car[tem%10];
}
StatusDp();
cout<<n-dp[5][1023]<<endl;
}
return 0;
}
边栏推荐
猜你喜欢

Container of the basic component of the flutter

RecyclerView 通用适配器封装

另类实现 ScrollView 下拉头部放大

自定义控件之侧滑关闭 Activity 控件

Flutter 基础组件之 Image

The collapsing "2.3 * 10 = 22" produced by multiplying float and int

任务调度器之Azkaban的使用

Time varying and non time varying

Codeforces Round #645 (Div. 2)

Using rancher to build kubernetes cluster
随机推荐
Is flush stock trading software reliable and safe?
2019.10.23训练总结
HDU 4578 Transformation(线段树+有技巧的懒标记下放)
JNI. H description
PHP内存马技术研究与查杀方法总结
Gmail:如何快速将邮件全部已读
Signal works: time varying and time invariant
Codeforces Round #657 Div. 2
51nod1277 字符串中的最大值【KMP】
动态规划总结
详细分析PBot挖矿病毒家族行为和所利用漏洞原理,提供蓝军详细防护建议
Binding mechanism of JVM methods
Memory layout of JVM objects
内网穿透工具frp使用入门
leetcode MYSQL数据库题目177
Leetcode MySQL database topic 180
2020-09-25 boost库的noncopyable,用于单例模式
Fully Automated Gross Tumor Volume Delineation From PET in Head and Neck Cancer Using Deep Learning
2019.11.13训练总结
JVM之方法的绑定机制