题目 liympanda, one of Ikki's friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play another game with Ikki. liympanda has a magic circle and he puts it on a…
注意到相交的点对一定要一里一外,这样就变成了2-SAT模型 然后我建边的时候石乐志,实际上不需要考虑这个点对的边是正着连还是反着连,因为不管怎么连,能相交的总会相交,所以直接判相交即可 然后tarjan缩点,再判是否合法即可 #include<iostream> #include<cstdio> using namespace std; const int N=100005; int n,m,h[N],cnt,l[N],r[N],dfn[N],low[N],tot,s[N],top…
Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 9426   Accepted: 3465 Description liympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy gam…
2-SAT. tarjan缩点.强连通分量的点要选一起选. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; + ; + ; int n,m; int a[maxn],b[maxn]; int g[maxn],v[maxm],next[maxm],eid; int dfn[maxn],vis[maxn],low[maxn],vid; int color[maxn],ci…
题目链接:http://poj.org/problem?id=3207 题意:在一个圆圈上有n个点,现在用线把点两两连接起来,线只能在圈外或者圈内,现给出m个限制,第 i 个点和第 j 个点必须链接在一起,问是否存在可行解. 容易想到圈内和圈外分别表示2sat的两种状态,对每一个限制 i 和 j ,考虑所有其它横跨他们的限制,然后连边就可以了. //STATUS:C++_AC_47MS_6300KB #include <functional> #include <algorithm>…
题目传送门 题意:在一个圆上顺时针安放着n个点,给出m条线段连接端点,要求线段不相交,线段可以在圆内也可以在圆外,问是否可以. 思路:假设一条线段,放在圆外是A,放在园内是A',那么两条线段如果必须一个放圆内一个放圆外的条件就是 端点区间相交(严格相交),所以就建立了2-SAT模型,然后跑2-SAT的模板就可以了. //#include<bits/stdc++.h> #include<stdio.h> #include<iostream> #include<std…
---题面--- 题意:给定一个圈,m条边(给定),边可以通过外面连,也可以通过里面连,问连完这m条边后,是否可以做到边两两不相交 题解: 将连里面和连外面分别当做一种决策(即每条边都是决策点), 如果有两条边相冲突,即如果这两条边都连里面就会导致不合法,那就 x --- > y' , y --- > x', 额...那怎么判断不合法? 注意到被边u ---> v(u < v)割成两半的分别是: u ~ v,其他, 一条边不经过这条边的充要条件是:两个端点都在这条边的同一侧. 也就…
POJ 3207 Ikki's Story IV - Panda's Trick liympanda, one of Ikki's friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play another game with Ikki. liympanda…
POJ 3207 Ikki's Story IV - Panda's Trick(2-sat问题) Description liympanda, one of Ikki's friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play another game…
Ikki's Story IV - Panda's Trick Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 7296   Accepted: 2705 Description liympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many tim…