BZOJ1520 [POI2006]Szk-Schools】的更多相关文章

裸的费用流啊... 建图:对于一个点p拆成两个p1和p2,S向p1连边,流量为1,费用为0:p2向T连边流量为1,费用为0 然后i1向a2到b2分别连边,不妨设i1向p2连边,流量为1,费用为|i - p| * ki 跑一下费用流,如果流量不为n,NIE!然后答案就是费用之和... /************************************************************** Problem: 1520 User: rausen Language: C++ Res…
注意:建图的时候,一定要把旧标号相同的分开. #include<cstdio> #include<algorithm> #include<cstring> #include<queue> using namespace std; #define MAXN 5001 #define MAXM 100001 #define INF 2147483647 int S,T,n,x,A,B,C; int en,u[MAXM],v[MAXM],first[MAXN],n…
[BZOJ1520][POI2006]Szk-Schools Description Input Output 如果有可行解, 输出最小代价,否则输出NIE. Sample Input 5 1 1 2 3 1 1 5 1 3 2 5 5 4 1 5 10 3 3 3 1 Sample Output 9 题解:二分图最小权匹配裸题,可以直接无脑费用流,不过这里就当复习一下KM算法了. #include <cstdio> #include <cstring> #include <…
题目描述 输入 输出 如果有可行解, 输出最小代价,否则输出NIE. 样例输入 5 1 1 2 3 1 1 5 1 3 2 5 5 4 1 5 10 3 3 3 1 样例输出 9 题解 费用流 设xi表示学生,yi表示编号,那么S->xi,容量为1,费用为0:xi->能够使得xi接受的yj,容量为1,费用为按照题目中计算出来的相应费用:yi->T,容量为1,费用为0. 然后跑最小费用最大流即可. #include <cstdio> #include <cstring&g…
Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16571   Accepted: 6558 Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a li…
Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16806   Accepted: 6643 Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a li…
Network of Schools Time Limit: 1000MS Memory Limit: 10000K Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes softwa…
1121: [POI2008]激光发射器SZK Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 792  Solved: 653[Submit][Status][Discuss] Description 多边形相邻边垂直,边长为整数,边平行坐标轴.要在多边形的点上放一些激光发射器和接收器.满足下列要求: 1发射器和接收器不能放置在同一点: 2发射器发出激光可以沿壁反射,最终到达一个接收器: 3发射器只能沿角平分线发射激光.求:最多可放置多少对发射器…
1121: [POI2008]激光发射器SZK Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 682  Solved: 565[Submit][Status][Discuss] Description 多边形相邻边垂直,边长为整数,边平行坐标轴.要在多边形的点上放一些激光发射器和接收器.满足下列要求: 1发射器和接收器不能放置在同一点: 2发射器发出激光可以沿壁反射,最终到达一个接收器: 3发射器只能沿角平分线发射激光.求:最多可放置多少对发射器…
传送门 Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the “receiving schools”). Note that if B is in the…