题意:

  就是一个圈上有n个点,给出m对个点,这m对个点,每一对都有一条边,合理安排这些边在圈内或圈外,能否不相交

解析:

  我手残 我手残 我手残

写一下情况 只能是一个在圈外 一个在圈内

即一个1一个0

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define pd(a) printf("%d\n", a);
#define plld(a) printf("%lld\n", a);
#define pc(a) printf("%c\n", a);
#define ps(a) printf("%s\n", a);
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = 1e5 + , INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff;
int n, m;
int sccno[maxn], vis[maxn], low[maxn], scc_cnt, scc_clock;
stack<int> S;
vector<int> G[maxn];
struct node
{
int x, y;
}Node[maxn]; void init()
{
mem(sccno, );
mem(vis, );
mem(low, );
for(int i = ; i < maxn; i++) G[i].clear();
scc_cnt = scc_clock = ;
} void dfs(int u)
{
low[u] = vis[u] = ++scc_clock;
S.push(u);
for(int i = ; i < G[u].size(); i++)
{
int v = G[u][i];
if(!vis[v])
{
dfs(v);
low[u] = min(low[u], low[v]);
}
else if(!sccno[v])
low[u] = min(low[u], vis[v]);
}
if(vis[u] == low[u])
{
scc_cnt++;
for(;;)
{
int x = S.top(); S.pop();
sccno[x] = scc_cnt;
if(x == u) break;
}
}
} bool check()
{
for(int i = ; i < n * ; i += )
if(sccno[i] == sccno[i^])
return false;
return true;
} int main()
{
init();
cin >> n >> m;
for(int i = ; i < m; i++)
{
cin >> Node[i].x >> Node[i].y;
}
for(int i = ; i < m; i++)
{
for(int j = i + ; j < m; j++)
{
int x1 = Node[i].x, y1 = Node[i].y, x2 = Node[j].x, y2 = Node[j].y;
if(x1 > y1) swap(x1, y1);
if(x2 > y2) swap(x2, y2);
if(x2 > x1 && x2 < y1 && y2 > y1 || x2 < x1 && y2 > x1 && y2 < y1 || x1 > x2 && x1 < y2 && y1 > y2 || x1 < x2 && y1 > x2 && y1 < y2)
{
G[i << | ].push_back(j << );
G[j << ].push_back(i << | );
G[j << | ].push_back(i << );
G[i << ].push_back(j << | );
}
}
}
for(int i = ; i < n * ; i++)
if(!vis[i]) dfs(i);
if(check()) cout << "panda is telling the truth..." << endl;
else cout << "the evil panda is lying again" << endl; return ;
}

Ikki's Story IV - Panda's Trick POJ - 3207(水2 - sat 在圈内 还是 在圈外)的更多相关文章

  1. Ikki's Story IV - Panda's Trick POJ - 3207_dfs跑2-SAT

    Code: #include<cstdio> #include<algorithm> #include<vector> using namespace std; c ...

  2. POJ 3207 Ikki's Story IV - Panda's Trick

    Ikki's Story IV - Panda's Trick Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 7296   ...

  3. poj 3207 Ikki's Story IV - Panda's Trick (2-SAT)

    http://poj.org/problem?id=3207 Ikki's Story IV - Panda's Trick Time Limit: 1000MS   Memory Limit: 13 ...

  4. POJ 3207 Ikki's Story IV - Panda's Trick(2-sat问题)

    POJ 3207 Ikki's Story IV - Panda's Trick(2-sat问题) Description liympanda, one of Ikki's friend, likes ...

  5. POJ 3207 Ikki's Story IV - Panda's Trick (2-sat)

    Ikki's Story IV - Panda's Trick Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6691   ...

  6. 【POJ3207】Ikki's Story IV - Panda's Trick

    POJ 3207 Ikki's Story IV - Panda's Trick liympanda, one of Ikki's friend, likes playing games with I ...

  7. POJ-3207 Ikki's Story IV - Panda's Trick 2sat

    题目链接:http://poj.org/problem?id=3207 题意:在一个圆圈上有n个点,现在用线把点两两连接起来,线只能在圈外或者圈内,现给出m个限制,第 i 个点和第 j 个点必须链接在 ...

  8. Ikki's Story IV - Panda's Trick

    poj3207:http://poj.org/problem?id=3207 题意::平面上有一个圆,圆的边上按顺时针放着0..n-1共n个点.现在要连m条边,比如a,b,那么a到b可以从圆的内部连接 ...

  9. poj3207 Ikki's Story IV - Panda's Trick 2-SAT

    题目传送门 题意:在一个圆上顺时针安放着n个点,给出m条线段连接端点,要求线段不相交,线段可以在圆内也可以在圆外,问是否可以. 思路:假设一条线段,放在圆外是A,放在园内是A',那么两条线段如果必须一 ...

随机推荐

  1. vuex mapState、mapGetters、mapActions、mapMutations的使用

    例子: index.js import Vue from 'vue' import Vuex from 'vuex' import mutations from './mutations' impor ...

  2. 十九、多文件上传(ajaxFileupload实现多文件上传功能)

    来源于https://www.jb51.net/article/128647.htm 打开google 搜索"ajaxFileupload' ‘多文件上传"可以搜到许许多多类似的, ...

  3. awk分析mysql状态

    今天是腊月27,明天是腊月28,一到过年,就习惯说农历,而不说公历.这两天挺闲的,就再造一把. 话说Linux处理文本工具有三剑客,awk.grep.sed,其中awk最为厉害,grep也挺是常用.今 ...

  4. Python学习第十二篇——切片的使用

    Python中使用函数切片可以创建副本,保留原本.现在给出如下代码 magicians_list = ['mole','jack','lucy'] new_lists = [] def make_gr ...

  5. mybatis的mapper注入失败

    因为处在两个不同的资源文件夹下: 导致classpath无法加载其中一些文件,所以修改为classpath*后顺利进行. <!-- 加载spring容器 --> <!-- neede ...

  6. redis的spring的xml配置

    <!-- 集群版配置 --> <bean id="jedisCluster" class="redis.clients.jedis.JedisClust ...

  7. bootstrap简单使用

    Bootstrap (版本 v3.3.7)     官网教程: https://v3.bootcss.com/css/ row——行 row——列 push——推   pull——拉 col-md-o ...

  8. Mysql drop function xxxx ERROR 1305 (42000): FUNCTION (UDF) xxxx does not exist

    mysql> drop function GetEmployeeInformationByID;ERROR 1305 (42000): FUNCTION (UDF) GetEmployeeInf ...

  9. 47.Majority Element I & II

    Majority Element I 描述 给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一. You may assume that the array is non ...

  10. vue二次实战(一)

    创建好项目(npm run dev 运行项目:先不用运行,或先运行再关闭) 先安装axios! npm install axios 然后! npm install --save axios vue-a ...