[BZOJ 1997][HNOI2010]Planar(2-SAT)】的更多相关文章

平面图中E ≤ V*2-6.. 一个圈上2个点的边可以是在外或者内, 经典的2sat问题.. ------------------------------------------------------------------------------------------ #include<cstdio> #include<cstring> #include<algorithm> #include<stack>   using namespace std;…
1997: [Hnoi2010]Planar Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 2224  Solved: 824[Submit][Status][Discuss] Description Input Output Sample Input 2 6 9 1 4 1 5 1 6 2 4 2 5 2 6 3 4 3 5 3 6 1 4 2 5 3 6 5 5 1 2 2 3 3 4 4 5 5 1 1 2 3 4 5 Sample Outp…
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1997 分析: 考虑每条边是在圈子里面还是圈子外面 所以就变成了2-SAT判定问题了= =,于是求SCC,如果一个点对应的2个bool点在一个SCC中就无解了. 当然这样建图好像要TLE…… 然后就要上大杀器了:平面图|E|<=3|V|-6 所以,如果m>3n-6就直接输出NO了…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1997 平面图的一个定理:若边数大于(3*点数-6),则该图不是平面图. 然后就可以2-SAT了! 注意把输入读完再用定理continue!!! 注意边是元素,所以是i+m,而且数组也应开成M<<1!!! #include<iostream> #include<cstdio> #include<cstring> using namespace std;…
#include<cstdio> #include<cstring> #include<iostream> #define M 20005 #define N 2005 using namespace std; *M],u[*M],x[M],y[M],pos[N],cnt,tot,c[N],dfn[N],low[N],f[N],tim,t,z[M],sum,shu[M]; void tarjan(int x) { f[x]=;z[++t]=x; low[x]=dfn[x…
脑补一下给出的图:一个环,然后有若干连接环点的边,我们就是要求这些边不重叠 考虑一下不重叠的情况,两个有交边一定要一个在环内一个在环外,所以把相交的边连边,然后跑黑白染色看是否能不矛盾即可(可能算个2-SAT?) #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=100005; int T,n,m,q[N],a[205][205],cnt,h[N]…
1997: [Hnoi2010]Planar 链接 分析: 首先在给定的那个环上考虑进行操作,如果环内有有两条边相交,那么可以把其中的一条放到环的外面去.所以转换为2-sat问题. 像这样,由于1-4和2-3在环内相交了,所以可以把1-4放到环外,就变成了下图. 代码: #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<cmath>…
http://www.lydsy.com/JudgeOnline/problem.php?id=1997 如果两条边在环内相交,那么一定也在环外相交 所以环内相交的两条边,必须一条在环内,一条在环外 这就成了2-sat问题 时间复杂度为(T*(m^2+n)),T 飞 平面图有一个结论:边数<=点数*3-6 m就与n同阶了 判断两条边是否在环内相交: 设一条边为(ui,vi),一条半为(uj,vj) 且 u在环上的编号<v 如果 ui<uj<vi<vj,则两条边会在环内相交 #…
开始填连通分量的大坑了= = 然后平面图有个性质m<=3*n-6..... 由平面图的欧拉定理n-m+r=2(r为平面图的面的个数),在极大平面图的情况可以代入得到m=3*n-6. 网上的证明(雾?): http://blog.chinaunix.net/uid-26510579-id-3183558.html http://www.zybang.com/question/673815bbe56e8b5639f95234b515b8c5.html 这题把哈密顿回路看成圆,就变成圆上的点之间的边是…
http://www.lydsy.com/JudgeOnline/problem.php?id=1997 1997: [Hnoi2010]Planar Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1810  Solved: 684[Submit][Status][Discuss] Description Input Output Sample Input 2 6 9 1 4 1 5 1 6 2 4 2 5 2 6 3 4 3 5 3 6 1 4…