/* 2sat问题 输出任意一组可行解 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<queue> #include<vector> using namespace std; #define N 2100 struct node { int u,v,next; }ff[N],bian[N*N*8]; int…
Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8170   Accepted: 2784   Special Judge Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old le…
Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1247    Accepted Submission(s): 542Special Judge Problem Description Your old uncle Tom inherited a piece of land from…
https://www.luogu.org/problemnew/show/P4174 最大权闭合子图的模板 每个通讯站建一个点,点权为-Pi:每个用户建一个点,点权为Ci,分别向Ai和Bi对应的点连边:然后就可以跑了 方法是: 建新源S和新汇T,从S向所有正权点连边,容量为点权值:从所有负权点向T连边,容量为点权值的相反数:原图中所有边容量设为无穷大 跑S到T最大流 原因:(网上都有,自己研究的也不知道有没有偏差) 找出图的任意一个割,其中: 显然不可能割掉容量为无穷大的边: 割掉一条S到u的…
转载地址:http://blog.csdn.net/qq172108805/article/details/7603351 /* 2-sat问题,题意:有对情侣结婚,请来n-1对夫妇,算上他们自己共n对,编号为0~~n-1,他们自己编号为0 所有人坐在桌子两旁,新娘不想看到对面的人有夫妻关系或偷奸关系,若有解,输出一组解,无解输出bad luck 思路: 1.根据偷奸关系建图(1h和2h有偷奸关系,建边1h->2w 2h->1w) 2.求强连通分量 3.判断有无解(任一对夫妇不在同一强连通分量…
题目地址:POJ 3683 第一次做须要输出可行解的题目. . .大体思路是先用强连通来推断是否有可行解,然后用逆序建图.用拓扑排序来进行染色.然后输出可行解. 详细思路见传送门 由于推断的时候少写了一个等号..检查了好长时间..sad... 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h>…
Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6900   Accepted: 2363   Special Judge Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old le…
题目链接:http://poj.org/problem?id=3683 思路:对于每个结婚仪式,只有在开始或结束时进行这两种选择,我们可以定义xi为真当且仅当在开始时进行.于是我们可以通过时间先后确定矛盾关系,然后通过矛盾关系建图.至于输出一组可行解,就可以2次dfs(一次沿正向边,一次沿反向边)求出拓扑序,然后根据拓扑序输出可行解. http://paste.ubuntu.com/5983686/…
Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10010   Accepted: 3425   Special Judge Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old l…
POJ 3683 Priest John's Busiest Day / OpenJ_Bailian 3788 Priest John's Busiest Day(2-sat问题) Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an old legend in the town that the couple w…