HDU - 4370 0 or 1】的更多相关文章

0 or 1 题目链接: Rhttp://acm.hust.edu.cn/vjudge/contest/122685#problem/R Description Given a n*n matrix C ij (1<=i,j<=n),We want to find a n*n matrix X ij (1<=i,j<=n),which is 0 or 1. Besides,X ij meets the following conditions: 1.X 12+X 13+...X 1…
0 or 1 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2811    Accepted Submission(s): 914 Problem Description Given a n*n matrix Cij (1<=i,j<=n),We want to find a n*n matrix Xij (1<=i,j<…
HDU - 4370 参考:https://www.cnblogs.com/hollowstory/p/5670128.html 题意: 给定一个矩阵C, 构造一个A矩阵,满足条件: 1.X12+X13+...X1n=1 2.X1n+X2n+...Xn-1n=1 3.for each i (1<i<n), satisfies ∑Xki (1<=k<=n)=∑Xij (1<=j<=n). 使得∑Cij*Xij(1<=i,j<=n)最小. 思路: 理解条件之前先…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4370 题目大意:有一个n*n的矩阵Cij(1<=i,j<=n),要找到矩阵Xij(i<=1,j<=n)满足以下条件: 1.X 12+X 13+...X 1n=1  2.X 1n+X 2n+...X n-1n=1  3.for each i (1<i<n), satisfies ∑X ki (1<=k<=n)=∑X ij (1<=j<=n). 举个例子…
[题目链接](http://acm.hdu.edu.cn/showproblem.ph Problem Description Given a n/n matrix Cij (1<=i,j<=n),We want to find a n/n matrix Xij (1<=i,j<=n),which is 0 or 1. Besides,Xij meets the following conditions: 1.X12+X13+...X1n=1 2.X1n+X2n+...Xn-1n=…
题目传送门 题意:题目巨晦涩的传递出1点和n点的初度等于入度等于1, 其余点出度和入度相等 分析:求最小和可以转换成求最短路,这样符合条件,但是还有一种情况.1点形成一个环,n点也形成一个环,这样也是可以的,这样SPFA要稍微修改点,d[s] = INF,表示可以更新. #include <bits/stdc++.h> using namespace std; const int N = 3e2 + 5; const int INF = 0x3f3f3f3f; int w[N][N]; int…
Description Given a n*n matrix C ij (1<=i,j<=n),We want to find a n*n matrix X ij (1<=i,j<=n),which is 0 or 1. Besides,X ij meets the following conditions: 1.X 12+X 13+...X 1n=1 2.X 1n+X 2n+...X n-1n=1 3.for each i (1<i<n), satisfies ∑X…
<题目链接> 题目大意: 一个n*n的01矩阵,满足以下条件 1.X12+X13+...X1n=12.X1n+X2n+...Xn-1n=13.for each i (1<i<n), satisfies ∑Xki (1<=k<=n)=∑Xij (1<=j<=n). 另给出一个矩阵C,求∑Cij*Xij(1<=i,j<=n)的最小值. 解题分析: 显然,题目给的是一个0/1规划模型. 解题的关键在于如何看出这个模型的本质. 3个条件明显在刻画未知数之…
题目描述 给定n * n矩阵C ij(1 <= i,j <= n),我们要找到0或1的n * n矩阵X ij(1 <= i,j <= n). 此外,X ij满足以下条件: 1.X 12 + X 13 + ... X 1n = 1 2.X 1n + X 2n + ... X n-1n = 1 3.对于每个i(1 <i <n),满足ΣXki(1 <= k <= n)=ΣXij(1 <= j <= n). 例如,如果n = 4,我们可以得到以下等式:…
思路:虽然是最短路专题里的,但也很难想到是最短路,如果能通过这些关系想到图论可能会有些思路.我们把X数组看做邻接矩阵,那么三个条件就转化为了:1.1的出度为1:2.n的入度为1:3.2~n-1的出度等于入度.C*X则是路径花费,最后求满足这些条件的路径的最少花费.满足这些条件的情况有两种:一是1到n的一条最短路径,二是1成自环,n成自环.最后找出两者最小值. 这里要注意下spfa的写法,因为需要成自环,所以dist[st]初始化为INF,保证成自环而非0:先让其他点入队. 代码: #includ…