POJ3436(最大流)

POJ3436-ACM Computer Factory 北大POJ3436-ACM Computer Factory 解题报告+AC代码 立即下载
ACM Computer Factory
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 8309 Accepted: 3017 Special 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,1Di,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

Hint

Bold texts appearing in the sample sections are informative and do not form part of the actual data.

Source

Northeastern Europe 2005, Far-Eastern Subregion

解题思路:把每个工厂拆成两个点,一个点为工厂需要的原料,一个点为工厂的产品,这两个点的容量为Qi,然后将每个工厂的产出点与其他工厂原料点相连(如果两点不矛盾,也就是产出可以作为另一个工厂的原料),容量为无穷大,定义一个源点s,连向所有的000点(不含1的都可以),定义一个汇点t,所有111的点连向这个汇点,这样我们求一个s到t的最大流就行。


#include <stdio.h>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
int p, n;
int s, t;
int tot;
int level[1000];//每个点的层次
bool visit[1000];
int head[1000];
struct Factory{
    int In[15], Out[15], value;
}Fa[60];
struct edge{
    int v, w, last;
}Edge[1000];
struct info{
    int u, v, w;
    bool operator <(const info &res) const {
        if(u == res.u) return v < res.v;
        else return u < res.u;
    }
}Info[1000];
edge Ori[1000];//备份原图
void add(int u, int v, int w)
{
    Edge[tot].v = v;
    Edge[tot].w = w;
    Edge[tot].last = head[u];
    head[u] = tot++;
    //添加反向边
    Edge[tot].v = u;
    Edge[tot].w = 0;
    Edge[tot].last = head[v];
    head[v] = tot++;

}
void init()
{
    tot = 0;
    memset(head, -1, sizeof(head));
    s = 0;
    t = 2 * n + 1;
}
bool judge_s(int x)
{
    for(int i = 1; i <= p; i++)
    {
        if(Fa[x].In[i] == 1) return false;
    }
    return true;
}
bool judge_t(int x)
{
    for(int i = 1; i <= p; i++)
    {
        if(Fa[x].Out[i] != 1) return false;
    }
    return true;
}
bool judge(int x, int y)//判断x工厂的产物是否能作为y工厂的原料
{
    for(int i = 1; i <= p; i++)
    {
        if(Fa[y].In[i] == 2) continue;
        else if(Fa[y].In[i] == 0 && Fa[x].Out[i] == 1) return false;
        else if(Fa[y].In[i] == 1 && Fa[x].Out[i] == 0) return false;
    }
    return true;
}
bool bfs()
{
    queue<int> q;
    while(!q.empty()) q.pop();
    memset(level, -1, sizeof(level));
    memset(visit, false, sizeof(visit));
    q.push(s);
    level[s] = 0;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        if(u == t) return true;
        visit[u] = true;
        for(int i = head[u]; i != -1; i = Edge[i].last)
        {
            int v = Edge[i].v;
            if(!visit[v] && Edge[i].w)
            {
                visit[v] = true;
                level[v] = level[u] + 1;
                q.push(v);
            }
        }
    }
    return false;
}
int dfs(int ss, int tt, int ff)
{
    //ss 为起点, tt 为终点, ff为流入起点的流量
    int res = 0;//流入该点后已经使用过的流量
    if(ss == tt) return ff;
    for(int i = head[ss]; i != -1; i = Edge[i].last)
    {
        int v = Edge[i].v;
        int w = Edge[i].w;
        int term = min(ff - res, w);
        if(level[v] == level[ss] + 1 && term)
        {
            int temp = dfs(v, tt, term);
            Edge[i^1].w += temp;
            Edge[i].w -= temp;
            res += temp;
            if(res == ff) return res;
        }
    }
    return res;
}
int Dinic()
{
    int Maxflow = 0;
    while(bfs())
    {
        Maxflow += dfs(s, t, inf);
        //cout<<"Maxflow == "<<Maxflow<<endl;
    }
    return Maxflow;
}
int main()
{
    scanf("%d%d", &p, &n);
    init();
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &Fa[i].value);
        for(int j = 1; j <= p; j++)
        {
            scanf("%d", &Fa[i].In[j]);
        }
        for(int j = 1; j <= p; j++)
        {
            scanf("%d", &Fa[i].Out[j]);
        }
    }
    //建图
    for(int i = 1; i <= n; i++)
    {
        if(judge_s(i)) add(s, i, inf);
        if(judge_t(i)) add(i, t, Fa[i].value);
        else add(i, i + n, Fa[i].value);
        for(int j = 1; j <= n; j++)
        {
            if(j == i) continue;
            if(judge(i, j)) add(i + n, j, Fa[i].value);
        }
    }
    //备份原图
    for(int i = 0; i < tot; i++)
    {
        Ori[i] = Edge[i];
    }
    //求解最大流
    int Maxflow = Dinic();
    //利用原图进行求解边
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(judge_t(i)) continue;
        for(int j = head[i + n]; j != -1; j = Edge[j].last)
        {
            int v = Edge[j].v;
            int w = Edge[j].w;
            if(v == i) continue;
            int ww = Ori[j].w;
            if(w == ww) continue;
            Info[++ans].u = i;
            Info[ans].v = v;
            Info[ans].w = ww - w;
        }
    }
    printf("%d %d\n", Maxflow, ans);
    for(int i = 1; i <= ans; i++)
    {
        printf("%d %d %d\n", Info[i].u, Info[i].v, Info[i].w);
    }
    return 0;

}




Autodesk全家桶:从AutoCAD到Maya,设计师必备的7款神器全解析 本文全面解析Autodesk全家桶中的7款设计师必备软件,包括AutoCAD、Revit、Inventor、Fusion 360、Maya和3ds Max等。从二维制图到三维建模,从建筑信息模型(BIM)到影视动画制作,这些工具在工程设计、建筑可视化和数字创意领域展现出强大的协同效应。通过实战案例展示如何整合工作流,显著提升设计效率与项目质量。 阅读详情

相关推荐

bcftools实战指南:从VCF文件处理到变异分析全流程解析

在基因组数据分析中,VCF(Variant Call Format)文件是存储基因序列变异信息的标准格式,广泛应用于群体遗传学和生物信息学研究。其核心原理是通过结构化文本记录SNP、INDEL等变异位点的基因型、质量值和注释信息。掌握高效处理VCF文件的技术,对于提升变异检测、数据清洗和下游分析的工作流效率具有重要价值。在生物信息学工具生态中,bcftools作为处理VCF/BCF文件的瑞士军刀,通过模块化设计实现了数据查询、过滤、统计和格式转换等核心功能。其流式处理架构支持管道化操作,能有效应对海量基因组

weixin_29081703的博客 323

POJ - 3436 ACM Computer Factory 网络流

POJ-3436:http://poj.org/problem?id=3436 题意   组配计算机,每个机器的能力为x,只能处理一定条件的计算机,能输出特定的计算机配置。进去的要求有1,进来的计算机这个位子就要求为1,进去的要求有0,进来的计算机这个位子就要求为0. 思路 因为点上有容量限制,所以把每个点拆掉,连一条容量为这个机器的能力的边。源点向要求为0的机器连容量inf的边,把能完全...

weixin_30451709的博客 146

Apifox CLI + Claude Skills:将接口自动化测试融入ai

基于 Apifox CLI、Claude Code以及Claude Skills组合,实现自然语言触发接口自动化测试。

wwz_0012的博客 599

poj - 3436 最大流dinic + 拆点 + 输出路径

题意: 第一行给你P和N, P表示配件的个数, N表示机器的数量,机器可用来组装电脑,把进来时拥有的配件变成出去时的配件 第二行首先给你一个数, 表示这个机器一天最大的组装量, 后面是2 * P 个数             1 ~ P表示电脑进入这个机器的配件要求, 0表示不能有这个配件, 1表示必须有这个配件, 2表示可有可无;             P + 1 ~ 2 * P表示电...

陌离将离 550

磁感应强度B、磁场强度H、矢量磁位A的study

学完电磁场很久了但是对电磁场中磁感应强度B⃗\vec{B}B、磁场强度HHH、矢量磁位A⃗\vec{A}A,这几个变量所表征的含义一直很模糊,所以就总结了一下

sinat_42386289的博客 1万+

从“Hello World”到区域赛银牌:我的ACM算法打怪升级全记录(附各阶段工具包)

本文记录了作者从编程新手到ACM区域赛银牌获得者的完整学习历程,详细分享了各阶段的算法学习路线、刷题策略和实战经验。涵盖从基础算法到动态规划的系统训练方法,并附赠经过竞赛检验的工具包和资源清单,为算法竞赛爱好者提供实用参考。

weixin_29201859的博客 123

poj 3436 ACM Computer Factory

http://poj.org/problem?id=3436 网络流 最重要的是要建图呀 由于速度的限制 要进行拆点 然后求解就可以了 需要注意的地方 1,和原点相连的点 满足进入它的各零件要求是0或2 2,和终点相连的点 需要用拆点后的后一个点连接 代码: #include<iostream> #include<stdio.h> #inclu...

weixin_30916125的博客 119

LVGL(lv_canvas)

这篇文章介绍了LVGL图形库中的lv_canvas组件,主要内容包括: lv_canvas是一个绘图缓冲区对象,提供丰富的绘图API,可以理解为LVGL的"离屏画布"。 基本使用流程:创建缓冲区->创建canvas对象->设置缓存和尺寸->进行绘图操作。 详细列举了常用的绘图函数,如绘制线条、矩形、文字、图片等。 提供了示例代码展示如何创建画布并绘制一条红色线段。 介绍了canvas的典型应用场景,如动态波形绘制、自定义控件底图等。 对比了canvas与普通img的区别

m0_49476241的博客 1030

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

基于多头注意力时间卷积网络(MATCN)的虚拟电厂短期功率预测模型

​时空特征解耦​:TCN负责时间模式,注意力捕捉空间关联​动态门控机制​:自适应调整两种特征的融合比例​多尺度感知​:膨胀卷积覆盖5分钟到24小时的时间跨度​轻量化设计​:参数量比传统Transformer减少52%

hasakie的博客 323

Windows Docker + RK3588 部署 YOLO26-Pose 人体姿态检测

YOLO26-Pose 在 RK3588 上的部署流程是 Windows Docker 容器内 ONNX 导出 → RKNN 转换(INT8 量化)→ ADB 推送 → 板端 C++ 推理。YOLO26n-Pose 在 640 输入下全链路约 55 FPS,可以覆盖实时姿态检测需求。先在板端用单张图片验证关键点输出正确性,确认 C++ 后处理的解析逻辑无误后,再切换到摄像头实时推理。

m0_64661770的博客 98

Poj3436——ACM Computer Factory(最大流)

题意: 流水线上有N台机器装电脑,电脑有P个部件组成,每台机器有三个参数,产量,输入规格,输出规格;输入规格中0表示改部件不能有,1表示必须有,2无所谓;输出规格中0表示该部件没有,1表示有。问如何安排流水线使电脑产量最高。 思路: 每个机器都是一个结点,点上有容量。拆点,中间连一条边,容量设为产量。然后根据输入规格和输出规格建立网络。跑最大流,有流量的边就是方案中包含的边。 #include &...

CY05627的博客 266

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ 3436 ACM Computer Factory (最大流 + 输出路径)

POJ 3436 ACM Computer Factory 链接:http://poj.org/problem?id=3436 题意:每台电脑有P部分,可以通过不同的机器来进行加工。有N台机器,每台机器用2 P +1 个整数来描述:Qi  Si,1  Si,2 ...  Si,p  Di,1  Di,2. ..  Di,p,其中Qi 指定了机器的性能,表示每小时加工的电脑数量。Si,j

SIOFive的专栏 1485

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

[POJ 3436]ACM Computer Factory[最大流][打印路径]

题目链接:[POJ 3436]ACM Computer Factory[最大流][打印路径] 题意分析: 组装一台电脑需要P个部件,现在有N个生产线,每个生产线分三部分的描述:第一个数字代表,这台机器单位时间能接收多少部件,后面的前p个部分代表该生产线需要什么部件,0代表不需要,1代表需要,2代表可有可无(相当于不需要),后p个部分代表产生什么部件,0不产生,1产生。问,怎么样调动这些材料,让整

闲停 1538

POJ 3436 ACM Computer Factory 最大流输出路径

题目:http://poj.org/problem?id=3436 题意:题意真心很难懂啊。。。产品有p个状态,给定n个机器,给出每个机器要求加工前的状态是什么,且给出加工后的状态是什么。产品初始时状态全部为0,完成加工时状态全部为1。加工前有三种状态,为0和1状态要求产品的对应位置也要是0和1,2状态的话可以随意,加工后只有0和1状态 思路:拆点建图,然后在从汇点出发搜索残余网络中的反向边,

弱智就要多努力 951

POJ - 3436 ACM Computer Factory ( 最大流 )

POJ - 3436 题意:... 大意就是有几台机器可以把半成品加工成成品或者另外的半成品,问你最终每小时得到的最多的成品。 思路:那么由题目,这个机器出来的零件个数和另一个机器需要的零件相同时(2的位置不算),他们肯定有条线,但是这里可以看出,对机器每小时有限制数量,这是对点有限制,而不是对边有限制,所以需要拆点,我第一遍写的时候没拆,但是过了,估计数据比较弱..... 没拆点的: #

shinimashzi 293

poj3436 ACM Computer Factory, 最大流,输出路径

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

天亮说晚安 2270

直接用bfs来求最大流 poj3436

poj3436 求最大流的问题 虚拟出一个源点 和汇点 然后把输入都为0或者2的机器和源点相连接 把输出都为1的机器和汇点相连接 然后根据机器之间的信息把各个机器的输出和输入相链接 这里值得注意的是 每台机器的输入和输出之间也有链接 大小为每台机器每小时的产量#include <iostream> #include <deque> #include <algorithm> #

专栏 634

ACM Computer Factory POJ - 3436 (最大流 && 输出路径)

ACM Computer Factory POJ - 3436 (最大流 &amp;&amp; 输出路径) 题目链接 题目大意:有N台机器,每台机器有P部分,每部分都有各自的输入、输出规格,因此一台机器有P个输入规格,P个输出规格。每台机器有2*P+1种参数去描述:第一个参数Q:该机器的容量;接下来P个参数S:该机器各部分的输入规格;接下来P个参数D:该机器各部分的输出规格。 其中输入规格有...

deerly_的博客 319

POJ 3436:ACM Computer Factory(最大流记录路径)

http://poj.org/problem?id=3436 题意:题意很难懂。给出P N。接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2*P+1是代表输出 输入有三种情况,0,1,2.输出有0,1两种情况输入0代表不能有这个接口,1代表必须要有这个接口,2代表这个接口可有可无。输出0代表有这个接口,1代表没有这个接口。大概输出就是...

weixin_30822451的博客 104

POJ-3436 ACM Computer Factory 最大流

  题目链接:http://poj.org/problem?id=3436   题目噼里啪啦说了一大堆= =,其实很简单。对每个点拆点u-v,然后加限制容量,如果两个点之间可行,那么加边,容量INF,最后加源点s和汇点t,建立有向图后,求大流。只是这个题目的建图有点麻烦,果断用3进制优化后,内存减少了很多,处理上也方便了很多。 1 //STATUS:C++_AC_0MS_180KB ...

weixin_30892763的博客 120

[poj 3436]最大流+输出结果每条边流量

题目链接:http://poj.org/problem?id=3436 大力套kuangbin板过了orz #include<cstdio> #include<cstring> using namespace std; const int MAXN = 210; const int MAXM = 40010; const int INF = ...

weixin_30663391的博客 158

poj3436 ACM Computer Factory

poj3436 ACM Computer Factory 题意:   n个工厂加工电脑,电脑有p个部件。每个工厂加工的电脑必须是满足它对原材料的需求。p个部件,0代表不能有,1必须有,2代表可有可无。然后经过加工后,这个工厂输出的电脑各个部件的情况,0代表没有,1...

banggui5839的博客 258
上一篇: 864F(tarjan思想)
下一篇: POJ3281(最大流)
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值