zoj 3642 Just Another Information Sharing Problem

本文探讨了一个幼儿园中的信息分享问题,孩子们互相分享关于测试的信息,但每个人分享的数量不同。通过二分匹配算法解决最多能获取多少信息的问题。
Just Another Information Sharing Problem

Time Limit: 2 Seconds      Memory Limit: 65536 KB

There is going to be another test in the kindergarten. Again the teacher has already told every kid some information about the test in advance. This time, all the children share their information with others. But everyone just share some of his information. The teacher want to know how many information someone can get at most.

Input

There are multiple cases, about 50 cases.
The first line of each case contains an integer n, indicating there are n kids.
The following n lines describe the state of the ith student. "Ai Bi Ci x1 x2 ... xAi". The ith kid has Ai distinct information. The information id is x1x2 ... xAi. He is going to share at least Biinformation and at most Ci information. (0 ≤ Bi ≤ Ci ≤ Ai) When some kid share 0 information with others, he is still in the sharing state, and get the information shared by others(Though he doesn't provide anything).
The next line is a number m. You should find how many information kid m can get at most. (1 ≤ m ≤ n)The index of kids is from 1 to n. 

n is less than 200, and is positive. The information id is among [1,1000000]. There would be 200 distinct information at most.
The number of information each student carry is among [0,10]. Different kids may carry same information.

Each information can be shared by different kids at the same time.
Output

Just output the number of information that student can get at most.

Sample Input
2
2 1 2 3 4
0 0 0
2
2
2 1 1 5 6
1 1 1 5
2
Sample Output
2
2
Hint

Sample 1: kid 1 shares both information, kid 2 shares nothing. kid 2 can have 2 information.
Sample 2: kid 1 shares (6), kid 2 shares (5). Then kid 2 can have 2 information.

 

分析:二分匹配,将人拆成c个点(最小值b是没用的),再从他拥有的信息向这c个点分别建边。注意先排除题目求的人以及他拥有的信息

#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
const int N=2000;
int match[N],m1[1000001];
bool vis[N],h[200];
vector<int> g[N];
struct Kid{
	int a,b,c,x[10];
}K[200];
bool hungary(int u){
	int i,v,s=g[u].size();
	for(i=0;i<s;i++){
		v=g[u][i];
		if(!vis[v]){
			vis[v]=1;
			if(match[v]==-1||hungary(match[v])){
				match[v]=u;
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	int n,m,y,i,j,k,nf,ans;
	while(~scanf("%d",&n)){
		k=0;memset(m1,-1,sizeof(m1));
		for(i=0;i<n;i++){
			scanf("%d%d%d",&K[i].a,&K[i].b,&K[i].c);
			for(j=0;j<K[i].a;j++){
				scanf("%d",&y);
				if(m1[y]==-1)m1[y]=k++;
				K[i].x[j]=m1[y];
			}
		}
		scanf("%d",&m),m--;
		memset(h,0,sizeof(h));
		for(i=0;i<K[m].a;i++)h[K[m].x[i]]=1;
		nf=k;k=0;
		for(i=0;i<nf;i++)g[i].clear();
		for(i=0;i<n;i++)if(i!=m){
			for(y=0;y<K[i].c;y++){
				for(j=0;j<K[i].a;j++)if(!h[K[i].x[j]]){
					g[K[i].x[j]].push_back(k);
				}
				k++;
			}
		}
		ans=0;
		memset(match,-1,sizeof(match));
		for(i=0;i<nf;i++){
			memset(vis,0,sizeof(vis));
			if(hungary(i))ans++;
		}
		printf("%d\n",ans+K[m].a);
	}
	return 0;
}


 

内容概要:本文介绍了一种基于蒙特卡洛模拟和拉格朗日优化方法的电动汽车充电站有序充电调度策略,重点针对分时电价机制下的分散式优化问题。通过Matlab代码实现,构建了考虑用户充电需求、电网负荷平衡及电价波动的数学模【电动汽车充电站有序充电调度的分散式优化】基于蒙特卡诺和拉格朗日的电动汽车优化调度(分时电价调度)(Matlab代码实现)型,采用拉格朗日乘子法处理约束条件,结合蒙特卡洛方法模拟大量电动汽车的随机充电行为,实现对充电功率和时间的优化分配,旨在降低用户充电成本、平抑电网峰谷差并提升充电站运营效率。该方法体现了智能优化算法在电力系统调度中的实际应用价值。; 适合人群:具备一定电力系统基础知识和Matlab编程能力的研究生、科研人员及从事新能源汽车、智能电网相关领域的工程技术人员。; 使用场景及目标:①研究电动汽车有序充电调度策略的设计与仿真;②学习蒙特卡洛模拟与拉格朗日优化在能源系统中的联合应用;③掌握基于分时电价的需求响应优化建模方法;④为微电网、充电站运营管理提供技术支持和决策参考。; 阅读建议:建议读者结合Matlab代码深入理解算法实现细节,重点关注目标函数构建、约束条件处理及优化求解过程,可尝试调整参数设置以观察不同场景下的调度效果,进一步拓展至多目标优化或多类型负荷协调调度的研究。
内容概要:本文围绕面向制造业的鲁棒机器学习集成计算流程展开研究,提出了一套基于Python实现的综合性计算框架,旨在应对制造过程中数据不确定性、噪声干扰面向制造业的鲁棒机器学习集成计算流程研究(Python代码实现)及模型泛化能力不足等问题。该流程集成了数据预处理、特征工程、异常检测、模型训练与优化、鲁棒性增强及结果可视化等关键环节,结合集成学习方法提升预测精度与稳定性,适用于质量控制、设备故障预警、工艺参数优化等典型制造场景。文中通过实际案例验证了所提方法在提升模型鲁棒性和预测性能方面的有效性。; 适合人群:具备Python编程基础和机器学习基础知识,从事智能制造、工业数据分析及相关领域研究的研发人员与工程技术人员,尤其适合工作1-3年希望将机器学习应用于实际制造系统的开发者。; 使用场景及目标:①在制造环境中构建抗干扰能力强、稳定性高的预测模型;②实现对生产过程中的关键指标(如产品质量、设备状态)进行精准监控与预测;③提升传统制造系统向智能化转型过程中的数据驱动决策能力。; 阅读建议:建议读者结合文中提供的Python代码实例,逐步复现整个计算流程,并针对自身业务场景进行数据适配与模型调优,重点关注鲁棒性设计与集成策略的应用,以充分发挥该框架在复杂工业环境下的优势。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值