HDU 2686 MCMF】的更多相关文章

题意:两遍最长路,不能走重复点.和UVA 10806类似. 分析:拆点,u->u',MCMF,求的是最大流的最小费用,那么cost取负. 注意的是源点,源点不用拆,那么走出来的最小费用,左上角的点,右下角的点走了两遍,输出除去即可. #include <bits/stdc++.h> using namespace std; +; const int INF = 0x3f3f3f3f; struct Edge { int from, to, cap, flow, cost; }; stru…
HDU 2686 Matrix 题目链接 3376 Matrix Again 题目链接 题意:这两题是一样的,仅仅是数据范围不一样,都是一个矩阵,从左上角走到右下角在从右下角走到左上角能得到最大价值 思路:拆点.建图,然后跑费用流就可以,只是HDU3376这题,极限情况是300W条边,然后卡时间过了2333 代码: #include <cstdio> #include <cstring> #include <vector> #include <queue>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n Matrix. A positive integer number is put in each area of the Matrix.Every time yifenfei should to do is that choose a detour which frome the top left…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 思路:多线程dp,参考51Nod 1084:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1084 注:这道题用滚动数组优化反而WA,压到三维即可 代码: #include <bits/stdc++.h> using namespace std; ][],dp[][][]; int main() { int n;…
http://acm.hdu.edu.cn/showproblem.php?pid=2686     Problem Description Yifenfei very like play a number game in the n*n Matrix. A positive integer number is put in each area of the Matrix.Every time yifenfei should to do is that choose a detour which…
Matrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2350    Accepted Submission(s): 1241 Problem Description Yifenfei very like play a number game in the n*n Matrix. A positive integer number…
题目链接:pid=2686">http://acm.hdu.edu.cn/showproblem.php?pid=2686 和POJ3422一样 删掉K把汇点与源点的容量改为2(由于有两个方向的选择)就可以 #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <queue> #include <algorit…
题目链接:http://poj.org/problem?id=2686 思路:典型的状压dp题,dp[s][v]表示到达剩下的车票集合为S并且现在在城市v的状态所需要的最小的花费. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define inf 1<<30 int n,m,p,a,b; ]; ][]…
题意:给定一个有向带权图,使得每一个点都在一个环上,而且权之和最小. 分析:每个点在一个环上,入度 = 出度 = 1,拆点入点,出点,s到所有入点全部满载的最小费用MCMF; #include <bits/stdc++.h> using namespace std; *; const int INF = 0x3f3f3f3f; typedef pair<int,int> pii; struct Edge { int from, to, cap, flow, cost; }; str…
网上说这道题的题解是费用流 我粗粗看了一下数据范围,觉得出题者似乎是让我们用 “大(d)屁(p)” 的样子,为了尊重出题人,我还是写一写吧喵~ 首先,一条回路可以看做是两条路齐头并进,这是 大屁 和 费永柳 的共同思想 故我们可用一条条次对角线(即 x+y=k  的对角线)来划分状态 考虑枚举对角线上两个点 x1,y1,x2,y2很大力地用 f[x1][y1][x2][y2] 表示两条路分别走到 点(x1, y1)和 点(x2, y2)时的最佳方案 这样 f[x1][y1][x2][y2] 就可…