poj3436 ACM Computer Factory 拆点+网络流

全网首发!Yolov8_obb旋转框训练、测试、推理手把手教学(DOTA1.0数据集map50已达80%) 其中,images/train和images/val放置原始图片文件,labels/train_original和labels/val_original分别放置原始的标签文件,labels/train和labels/val为空,然后运行步骤(3)的代码,运行结束转换后的标签会保存在labels/train和labels/val中,格式如下。(4)新建yolov8-obb.yaml,修改nc和scales,我使用的是yolov8n.(2)构建数据集,安装下面目录格式,其他test可为空,一定要对应。 阅读详情
ACM Computer Factory
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 4674Accepted: 1582Special Judge

Description

As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historically produced at the same factory.

Every ACM computer consists of P parts. When all these parts are present, the computer is ready and can be shipped to one of the numerous ACM contests.

Computer manufacturing is fully automated by using N various machines. Each machine removes some parts from a half-finished computer and adds some new parts (removing of parts is sometimes necessary as the parts cannot be added to a computer in arbitrary order). Each machine is described by its performance (measured in computers per hour), input and output specification.

Input specification describes which parts must be present in a half-finished computer for the machine to be able to operate on it. The specification is a set of P numbers 0, 1 or 2 (one number for each part), where 0 means that corresponding part must not be present, 1 — the part is required, 2 — presence of the part doesn't matter.

Output specification describes the result of the operation, and is a set of P numbers 0 or 1, where 0 means that the part is absent, 1 — the part is present.

The machines are connected by very fast production lines so that delivery time is negligibly small compared to production time.

After many years of operation the overall performance of the ACM Computer Factory became insufficient for satisfying the growing contest needs. That is why ACM directorate decided to upgrade the factory.

As different machines were installed in different time periods, they were often not optimally connected to the existing factory machines. It was noted that the easiest way to upgrade the factory is to rearrange production lines. ACM directorate decided to entrust you with solving this problem.

Input

Input file contains integers P N, then N descriptions of the machines. The description of ith machine is represented as by 2 P + 1 integers Qi Si,1 Si,2...Si,P Di,1 Di,2...Di,P, where Qi specifies performance, Si,j — input specification for part j, Di,k — output specification for part k.

Constraints

1 ≤ P ≤ 10, 1 ≤ N ≤ 50, 1 ≤ Qi ≤ 10000

Output

Output the maximum possible overall performance, then M — number of connections that must be made, then M descriptions of the connections. Each connection between machines A and B must be described by three positive numbers A B W, where W is the number of computers delivered from A to B per hour.

If several solutions exist, output any of them.

Sample Input

Sample input 1
3 4
15  0 0 0  0 1 0
10  0 0 0  0 1 1
30  0 1 2  1 1 1
3   0 2 1  1 1 1
Sample input 2
3 5
5   0 0 0  0 1 0
100 0 1 0  1 0 1
3   0 1 0  1 1 0
1   1 0 1  1 1 0
300 1 1 2  1 1 1
Sample input 3
2 2
100  0 0  1 0
200  0 1  1 1

Sample Output

Sample output 1
25 2
1 3 15
2 3 10
Sample output 2
4 5
1 3 3
3 5 3
1 2 1
2 4 1
4 5 1
Sample output 3
0 0
 
    由于该题是节点流量限制,所以应该把每个点拆成两个点,从而转化成边流量限制。
建图:将每台机器看做一个节点,然后把每个节点拆成两个(i和i+n),建边i->i+n,边流量限制为该机器的速度;对于每台机器i,若s[j]=0||s[j]=2,则建边s->i,边流量限制为INF,若d[j]=1,则建边i+n->t,边流量限制为INF;然后枚举所有的机器对(i,j),若符合要求则建边i+n->j,边流量限制为INF。
    然后就可以求最大流了,最后输出所有流量大于0的边以及流量。
 
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
const int MAXN=55;
const int INF=(1<<29);
struct
{
    int q;
    int s[10],d[10];
}machine[MAXN];
struct Arc
{
    int c,f;
};
Arc flow[MAXN*2][MAXN*2];
int level[MAXN*2];
int p,n,s,t;

int bfs()
{
    int queue[MAXN*2],front,rear;
    front=rear=0;
    memset(level,0,sizeof(level));
    level[s]=1;
    queue[rear++]=s;
    while(front!=rear)
    {
        int v=queue[front++];
        for(int i=0;i<=t;i++)
        {
            if(!level[i]&&flow[v][i].f<flow[v][i].c)
            {
                level[i]=level[v]+1;
                queue[rear++]=i;
            }
        }
    }
    return level[t];
}

int dfs(int i,int f)
{
    if(i==t)
        return f;
    int sum=0;
    for(int j=0;f&&j<=t;j++)
    {
        if(level[j]==level[i]+1&&flow[i][j].f<flow[i][j].c)
        {
            int tmp=dfs(j,min(f,flow[i][j].c-flow[i][j].f));
            sum+=tmp;
            f-=tmp;
            flow[i][j].f+=tmp;
            flow[j][i].f-=tmp;
        }
    }
    return sum;
}

int dinic()
{
    int maxflow=0;
    while(bfs())
        maxflow+=dfs(s,INF);
    return maxflow;
}

int main()
{
    int i,j,k;
    int maxflow,route;
    while(~scanf("%d%d",&p,&n))
    {
        for(i=1;i<=n;i++)
        {
            scanf("%d",&machine[i].q);
            for(j=0;j<p;j++)
                scanf("%d",&machine[i].s[j]);
            for(j=0;j<p;j++)
                scanf("%d",&machine[i].d[j]);
        }
        s=0;
        t=2*n+1;
        for(i=0;i<=t;i++)
            for(j=0;j<=t;j++)
                flow[i][j].c=flow[i][j].f=0;
        for(i=1;i<=n;i++)
            flow[i][i+n].c=machine[i].q;
        for(i=1;i<=n;i++)
        {
            int sum=0;
            for(j=0;j<p;j++)
            {
                if(machine[i].s[j]==2)
                    continue;
                sum+=machine[i].s[j];
            }
            if(sum==0)
                flow[s][i].c=INF;
            sum=0;
            for(j=0;j<p;j++)
                sum+=machine[i].d[j];
            if(sum==p)
                flow[i+n][t].c=INF;
        }
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
            {
                if(i==j)
                    continue;
                k=0;
                while(k<p&&(machine[i].d[k]==machine[j].s[k]||machine[j].s[k]==2))
                    k++;
                if(k==p)
                    flow[i+n][j].c=INF;
            }
        maxflow=dinic();
        route=0;
        for(i=n+1;i<=t;i++)
            for(j=1;j<=n;j++)
                if(i-n!=j&&flow[i][j].f)
                    route++;
        printf("%d %d\n",maxflow,route);
        for(i=n+1;i<=t;i++)
            for(j=1;j<=n;j++)
                if(j!=i-n&&flow[i][j].f)
                    printf("%d %d %d\n",i-n,j,flow[i][j].f);
    }
    return 0;
}

Fortigate 在AWS中配置HA 方案1: 1、将两台服务器配置在相同可用区中,使用飞塔原生HA功能,可以实现配置同步功能。 2、配置SSLVPN,在主服务器不可用时,可以实现自动切换到备用服务器继续提供VPN服务。 当前问题: 1、主挂掉后可以自动切换到备,但是原主服务器修复后不会自动切换到主状态。 2、如下图所示切换中丢包明显,需要客户端开启“保持连接”功能。 配置过程如下: 1、整体架构 2、创建VPC和子网,如下图所示... 阅读详情

相关推荐

OpenModelica入门指南:从下载安装到第一个仿真模型(附常见问题解答)

本文提供OpenModelica开源项目的完整入门指南,涵盖从下载安装、界面熟悉到构建首个仿真模型的全过程。通过创建经典的阻尼震荡系统实例,详细讲解组件拖放、参数设置、仿真运行及结果分析,并附有常见问题解决方案,帮助工程师和研究人员快速上手这一强大的多领域物理系统建模与仿真工具。

weixin_29239279的博客 725

POJ 3436 ACM Computer Factory(拆点+前向星dinic)||(拆点+邻接矩阵dinic)||(不拆点+dinic))

题目大意:就是第一行两个数p,n分别代表电脑零件的个数,和有多少机器。接下来的n行每行2*p+1个数,第一个数为机器工作的效率,其余代表机器加工前和后电脑的变化,求机器一起工作的最大效率,并输出路径。 思路:由于源点的流入和普通链接点的流入,可能会大于当前点的容量,因此拆点.那么,怎么再判断有多少个机器用到了呢,这就要原来机器的工作效率,和剩余网络,如果原来的工作效率大于剩余网络那么一定

Grit_ICPC的博客 734

[金仓数据库V8R6]更换授权

上传授权,使用mv license_xxx_0.dat /home/kingbase/KingbaseES/license.dat替换每个授权,并使用ls -l license.dat确保替换前后属主和权限不变。根据步骤1的数据目录位置,执行/home/kingbase/KingbaseES/Server/bin/sys_ctl -D /home/kingbase/KingbaseES/data reload使新的授权文件生效。该参数意义为授权剩余有效天数,查询结果为新授权中有效期间的天数即为替换成功。

l04050924的博客 3706

ACM/ICPC 之 网络流-拆点构图(POJ2391)

  需要直接到达,因此源点经过三条边后必须要达到汇点,但为了保证网络流的正确性(路径可反悔),因此不可限制层次网络的最高层次为3,最好的方法既是让所有点拆分成两个点,一个点从汇点进入,一个点通向汇点,任意两点的路径则标注为最短路径。 //Dinic算法-拆点构图 //Time:625Ms Memory:2108K #include<iostream> ...

disuo8001的博客 209

【Unity3D】关于unity中spriteAtlas的打包方案及使用时内存状态的多组对照实验

unity项目中使用精灵(Sprite)为了降低性能消耗,我们可以使用精灵图集(Sprite Atlas)技术,它能够将多个纹理合并成一个大纹理

云渊寒烬 5100

Stata极简生存分析

1. 导入数据 webuse drugtr,clear *webuse -- Use dataset from Stata website stset,clear *上一行命令导入进来的数据是“生存时间数据”,会比最原始的数据多四列,这一行命令的目的是重置为原始数据,之所以这样做,是为了显示数据处理的全部过程 codebook drug codebook studytime codebook died codebook age *codebook -- Describe data contents 2.

TOP生物信息 2335

【POJ 3436 ACM Computer Factory】网络流 & 拆点 & Dinic

ACM Computer Factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8323 Accepted: 3027 Special Judge DescriptionAs you know, all the computers used for ACM contests must b

楚江枫 1041

大数据之数据抽取架构演变过程

而当时我们搭建的Flink集群是基于YARN进行资源管理和调度的,因为YARN中不仅仅包含着FLInk的资源,也有hive,zoozie,hdfs等等的资源,这样容易造成yarn资源的过度使用,容易引起整个底座的cpu以及内存的使用问题,经过排查,主要是由于FLink的使用资源引起的,所以后续就把Flink从整个集群中剥离出来,进行资源的隔离,最后Flink采用了StandAlone HA部署(但是这个目前还是存在问题,后续根据项目进行优化)'topic' = '表名',二、数据抽取架构的演变。

天道酬勤 866

POJ 3436 ACM Computer Factory 网络流+拆点限流

文章目录题目描述输入描述输出描述问题分析附上代码 题目描述 每台计算机都由ppp个部件组成,现在给出nnn个可以加工的工厂,每个工厂加工计算机时对计算机的部件有要求,给出ppp个数,000表示不能有该部件,111表示必须有这个部件,222表示有没有这个部件都可以加工,再给出ppp个数表示计算机出厂时的状态,000表示没有这个部件,111表示有这个部件。每个工厂还有加工的上限。让求出最大能生产多少计算机,即由全000状态到全111状态。同时输出从AAA工厂到BBB工厂发送多少台计算机。 输入描述 多组数据,每

_紫香妃的博客 262

医学图像处理实战:3D Slicer从安装到病灶分析全流程指南

本文提供了一份详尽的3D Slicer实战指南,涵盖从软件安装、DICOM数据导入到图像增强、病灶分割及三维可视化的全流程。重点演示了如何利用阈值分割、区域生长等核心图像处理技术进行病灶分析,并生成定量报告,是医学影像分析初学者的实用入门教程。

weixin_29278805的博客 600

利用HTML+CSS设计PPT:html-to-pptx实现自动化转换与可编辑输出

在办公自动化和前端开发领域,将网页技术应用于文档生成是一个重要的技术方向。其核心原理在于通过解析HTML/CSS的结构与样式,将其映射为目标文档的原生对象模型。这项技术的价值在于,它能够将Web技术栈强大的布局与样式能力(如Flexbox、CSS Grid)与办公软件(如Microsoft PowerPoint)的广泛兼容性和可编辑性相结合。在实际应用场景中,这种技术特别适合需要快速生成兼具设计感与实用性的演示文稿,例如数据报告、产品发布和营销材料。本文探讨的html-to-pptx项目正是这一思路的工程实

weixin_30652491的博客 486

POJ 3436 ACM Computer Factory(网络流 拆点)

POJ 3436题目大意 有一些机器用来装配电脑,每个电脑由P个部件构成,装配机要求传输过来的电脑有一定要求,一组P个数分别表示对每个部件的要求:0表示不需要这个部件,1表示需要这个部件,2表示有没有都可以。装配机的输出也有一定格式,也是P个数:0表示没有这个部件,1表示有这个部件。每个装配机有个效率可以理解成每小时装配多少个。装配机之间的连接不耗时,问这个网络,每小时最多装配多少个。 分析首先

AIDreamer 814

第1章 环境准备

本章是 Kubernetes 高可用集群部署的前置基础环境配置,所有节点必须严格按顺序执行。主要内容包括:节点规划(IP、角色、配置要求)、VMware 克隆节点环境清理(解决 MAC 地址和主机名冲突)、统一工作目录创建、主机名与 hosts 解析配置、系统基础升级、防火墙与 swap 关闭、内核模块加载(overlay、br_netfilter、ip_vs)、网络参数优化(IP 转发、桥接过滤)、时间同步配置等。Ubuntu 24.04 内核 6.8+ 原生支持 eBPF 和 IPVS,无需手动升级内核

幸福街--linux技术分享 210

POJ - 3436 ACM Computer Factory (拆点+网络流)

ACM Computer Factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9241   Accepted: 3412   Special Judge Description As you know, all the computers used for ACM ...

柳予欣的三味书屋~ 388

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

A - ACM Computer Factory POJ - 3436(网络流 - 最大流 - 拆点)

题目链接:https://vjudge.net/contest/68128#problem/A 算法:最大流 - 拆点 思路:把每台机器拆成两个点,中间用一条边连通,并将容量设为该机器的生成电脑的速度,通过机器的产出零件 和 机器的输入零件 来建边,不同机器之间的边容量设为无穷大。从而转化为最大流问题。输出时,将容量比原来小的且除源点汇点和拆点中的边以及反向边外的边输出即可。 #include &...

凝望的博客 302

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

POJ3436 ACM Computer Factory(多源点网络流,拆点,EK算法)

Description As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historically produced at t

riba2534的博客 609

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

ACM Computer Factory POJ - 3436 网络流拆点+路径还原

http://poj.org/problem?id=3436 每台电脑有$p$个组成部分,有$n$个工厂加工电脑。 每个工厂对于进入工厂的半成品的每个组成部分都有要求,由$p$个数字描述,0代表这个部分不能有,1代表这个部分必须有,2代表这个部分的有无无所谓。 每个工厂的产出也不尽相同,也是由p个数字代表,0代表这个部分不存在,1代表这个部分存在。每个工厂都有一个最大加工量。 给出这$n$...

weixin_30725315的博客 91

poj3436 ACM Computer Factory(网络流最大流 + 拆点 + 建图 + 输出路径)

ACM Computer Factory Time Limit:1000MS Memory Limit:65536K Total Submissions:12151 Accepted:4563 Special Judge Description As you know, all the computers used for ACM contests must be identical, so the participants compete o...

。 275

POJ 3436 :ACM Computer Factory:网络流拆点应用

ACM Computer Factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5384   Accepted: 1858   Special Judge Description As you know, all the computers used

smileyk的专栏 479

POJ 3436 ACM Computer Factory - (网络流)

题目链接:http://poj.org/problem?id=3436一直WA,把queue换成stack突然AC,,,,,很迷当然POJ还是不支持C++ 11,std::move()无法编译#include &lt;stdio.h&gt; #include &lt;vector&gt; #include &lt;queue&gt; using namespace std; //PO...

rsy56640的博客 255

POJ 3436 ACM Computer Factory(Dinic)

题意: 电脑公司生产电脑有N个机器,每个机器单位时间产量为Qi。 电脑由P个部件组成,每个机器工作时只能把有某些部件的半成品电脑(或什么都没有的空电脑)变成有另一些部件的半成品电脑或完整电脑(也可能移除某些部件)。求电脑公司的单位时间最大产量,以及哪些机器有协作关系,即一台机器把它的产品交给哪些机器加工。 Sample input 3 4 15 0 0 0 0 1 0

光明~~~ 2万+

poj_3436 ACM Computer Factory(Dinic + 拆点)

ACM Computer Factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7212   Accepted: 2566   Special Judge Description As you know, all the computers used

凳子 381

POJ - 3436 ACM Computer Factory 最大流,拆点,输出路径,dinic

题目链接 POJ-3436 题意 有n个工厂加工商品,商品有m个零件,工厂有最大产能q。告诉你每个工厂能接受加工成什么样子的半成品,以及经这个工厂加工之后的产品情况,问最大能生产多少商品。 思路 看网上题解大多拆点,我这咋没拆。。 最大流题目,关键在于建图,建立超级源汇,源点向所有可以从0开始加工的工厂连边(具体到输入数据,就是输入的m个零件都为0或者2),容量为最大产能q。所有加工完毕的工厂(产出的m个零件都为1的)向汇点连边,容量为最大产能q。再枚举每个工厂A,向所有能接受这个A厂产品的工厂B连边(A厂

TheSunspot的博客 392

poj 3436 ACM Computer Factory 最大流拆点+输出路径

题目链接: poj3436 题意: 每台ACM 计算机包括P 个部件。当全部这些部件都准备齐全后,计算机就能够组装了。组装好以后就能够交给竞赛队伍使用了。计算机的生产过程是全自己主动的,通过N 台不同的机器来完毕。每台机器从一台半成品计算机中去掉一些部件。并增加一些新的部件(去除一些部件在有的时候是必须的,由于计算机的部件不能以随意的顺序组装...

adr5970的博客 189

POJ-3436-ACM Computer Factory(网络流)

链接:http://poj.org/problem?id=3436 拆点求最大流,并求出每边的流量。 #pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include using n

不会吃鱼的喵 396

POJ-3436 ACM Computer Factory

As you know, all the computers used for ACM contests must be identical, so the participants compete on equal terms. That is why all these computers are historically produced at the same factory. Ever...

qq_41304844的博客 294
上一篇: poj2391 Ombrophobic Bovines 拆点+网络流
下一篇: Tesseract学习(一)
捡石子的小孩
博客等级 码龄14年 51粉丝 117原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值