ACM Computer Factory POJ - 3436

ACM Computer Factory
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 8464 Accepted: 3080 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 ofP 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 ofith machine is represented as by 2 P + 1 integers Qi Si,1Si,2...Si,P Di,1Di,2...Di,P, whereQi specifies performance, Si,j — input specification for partj, Di,k — output specification for partk.

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, thenM descriptions of the connections. Each connection between machines A and B must be described by three positive numbers A B W, whereW 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

[Submit]   [Go Back]   [Status]   [Discuss]


题意:给出N台机器,流水线作业装配电脑,每台电脑有P种配件,每台机器有特定的输入输出:

0表示电脑没有此配件,1表示有此配件,机器输入参数中的2表示输入的电脑配件可有可无

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
用样例分析:机器1可把状态(0,0,0)转换成(0,1,0),再由机器3转换成(1,1,1)即完成装配,单位时间装配了15台


分析:

拆点:一台机器拆分出输入和输出两个点

容量:从超级源点s到起点(状态全0),从终点(状态全1)到超级终点t,不同机器之间,容量均为INF,输入和输出之间容量设为单位时间操作次数;


Ac code:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int INF =0x3f3f3f3f;
const int N=1000+50;


int w[N];
int in[N][N];
int out[N][N];
int n,p;

struct Edge {
    int from,to,cap,flow;
};
vector<Edge> edge;
vector<int> G[N];
int pre[N];//记录路径
int vis[N];//起点到i的可改进量

bool bfs(int s,int t) {
    memset(vis,0,sizeof(vis));
    queue<int>q;
    q.push(s);
    vis[s]=INF;
    while(!q.empty()) {
        int x=q.front();
        q.pop();
        for(int i=0; i<G[x].size(); i++) {
            Edge& e=edge[G[x][i]];
            if(!vis[e.to]&&e.cap>e.flow) {
                vis[e.to]=min(vis[x],e.cap-e.flow);
                pre[e.to]=G[x][i];
                q.push(e.to);
            }
        }
    }
    return vis[t];
}

int max_flow(int s,int t) {
    int flow=0;
    while(bfs(s,t)) {
        for(int u=t; u!=s; u=edge[pre[u]].from) {
            edge[pre[u]].flow+=vis[t];
            edge[pre[u]^1].flow-=vis[t];
        }
        flow+=vis[t];
    }
    return flow;
}
void add_edge(int from,int to,int cap) {
    edge.push_back((Edge) {from,to,cap,0});
    edge.push_back((Edge) {to,from,0,0});
    int m=edge.size();
    G[from].push_back(m-2);
    G[to].push_back(m-1);
}


int isStart(int x[]) {
    for(int i=1; i<=p; i++) {
        if(x[i]==1) return 0;
    }
    return 1;
}

int isEnd(int x[]) {
    for(int i=1; i<=p; i++) {
        if(x[i]==0) return 0;
    }
    return 1;
}

int isInAndOut(int in[],int out[]) {
    for(int i=1; i<=p; i++) {
        if(in[i]!=out[i]&&in[i]!=2) return 0;   //等于2可以任意
    }
    return 1;
}


void init(int n) {
    for(int i=0; i<=n; i++) {
        G[i].clear();
    }
    memset(in,0,sizeof in);
    memset(out,0,sizeof out);
    //memset(pre,0,sizeof pre);
}


int main() {
    while(~scanf("%d%d",&p,&n)) {
        int s=0;
        int t=2*n+1;
        init(t);
        for(int i=1; i<=n; i++) {
            scanf("%d",&w[i]);
            //拆点,入点和出点
            for(int j=1; j<=p; j++)
                scanf("%d",&in[i][j]);
            for(int j=1; j<=p; j++)
                scanf("%d",&out[i][j]);
            if(isStart(in[i])) add_edge(s,i,INF);       //1~n为入点
            if(isEnd(out[i])) add_edge(n+i,t,INF);      //n+1~2n为出点
        }

        for(int i=1; i<=n; i++) {
            add_edge(i,i+n,w[i]);
            for(int j=1; j<=n; j++) {
                if(i==j) continue;
                if(isInAndOut(in[i],out[j])) {
                    add_edge(j+n,i,INF);                //刚好可以连接
                }
            }
        }

        int ans=max_flow(s,t);
        int cnt=0;
        int path[N][3];
        for(int u=n+1; u<t; u++)for(int i=0; i<G[u].size(); i++) {
            Edge& e=edge[G[u][i]];
            if(e.to>0&&e.to<=n&&e.flow>0){
                path[cnt][0]=u-n;
                path[cnt][1]=e.to;
                path[cnt++][2]=e.flow;
            }
        }

        printf("%d %d\n",ans,cnt );
        for(int i=0;i<cnt;i++){
            printf("%d %d %d\n",path[i][0],path[i][1],path[i][2] );
        }
    }
    return 0;
}






本项目构建于RASA开源架构之上,旨在实现一个具备多模态交互能力的智能对话系统。该系统的核心模块涵盖自然语言理解、语音转文本处理以及动态对话流程控制三个主要方面。 在自然语言理解层面,研究重点集中于增强连续对话中的用户目标判定效能,并运用深度神经网络技术提升关键信息提取的精确度。目标判定旨在解析用户话语背后的真实需求,从而生成恰当的反馈;信息提取则专注于从语音输入中析出具有特定意义的要素,例如个体名称、空间位置或时间节点等具体参数。深度神经网络的应用显著优化了这些功能的实现效果,相比经典算法,其能够解析更为复杂的语言结构,展现出更优的识别精度与更强的适应性。通过分层特征学习机制,这类模型可深入捕捉语言数据中隐含的语义关联。 语音转文本处理模块承担将音频信号转化为结构化文本的关键任务。该技术的持续演进大幅提高了人机语音交互的自然度与流畅性,使语音界面日益成为高效便捷的沟通渠道。 动态对话流程控制系统负责维持交互过程的连贯性与逻辑性,包括话轮转换、上下文关联维护以及基于情境的决策生成。该系统需具备处理各类非常规输入的能力,例如用户使用非规范表达或对系统指引产生歧义的情况。 本系统适用于多种实际应用场景,如客户服务支持、个性化事务协助及智能教学辅导等。通过准确识别用户需求并提供对应信息或操作响应,系统能够创造连贯顺畅的交互体验。借助深度学习的自适应特性,系统还可持续优化语言模式理解能力,逐步完善对新兴表达方式与用户偏好的适应机制。 在技术实施方面,RASA框架为系统开发提供了基础支撑。该框架专为构建对话式人工智能应用而设计,支持多语言环境并拥有活跃的技术社区。利用其内置工具集,开发者可高效实现复杂的对话逻辑设计与部署流程。 配套资料可能包含补充学习文档、实例分析报告或实践指导手册,有助于使用者深入掌握系统原理与应用方法。技术文档则详细说明了系统的安装步骤、参数配置及操作流程,确保用户能够顺利完成系统集成工作。项目主体代码及说明文件均存放于指定目录中,构成完整的解决方案体系。 总体而言,本项目整合了自然语言理解、语音信号处理与深度学习技术,致力于打造能够进行复杂对话管理、精准需求解析与高效信息提取的智能语音交互平台。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值