Ikki's Story IV - Panda's Trick POJ - 3207(水2 - sat 在圈内 还是 在圈外)
题意:
就是一个圈上有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 在圈内 还是 在圈外)的更多相关文章
- Ikki's Story IV - Panda's Trick POJ - 3207_dfs跑2-SAT
		Code: #include<cstdio> #include<algorithm> #include<vector> using namespace std; c ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 【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 ... 
- POJ-3207 Ikki's Story IV - Panda's Trick 2sat
		题目链接:http://poj.org/problem?id=3207 题意:在一个圆圈上有n个点,现在用线把点两两连接起来,线只能在圈外或者圈内,现给出m个限制,第 i 个点和第 j 个点必须链接在 ... 
- Ikki's Story IV - Panda's Trick
		poj3207:http://poj.org/problem?id=3207 题意::平面上有一个圆,圆的边上按顺时针放着0..n-1共n个点.现在要连m条边,比如a,b,那么a到b可以从圆的内部连接 ... 
- poj3207     Ikki's Story IV - Panda's Trick      2-SAT
		题目传送门 题意:在一个圆上顺时针安放着n个点,给出m条线段连接端点,要求线段不相交,线段可以在圆内也可以在圆外,问是否可以. 思路:假设一条线段,放在圆外是A,放在园内是A',那么两条线段如果必须一 ... 
随机推荐
- 【全网最全的博客美化系列教程】01.添加Github项目链接
			全网最全的博客美化系列教程相关文章目录 [全网最全的博客美化系列教程]01.添加Github项目链接 [全网最全的博客美化系列教程]02.添加QQ交谈链接 [全网最全的博客美化系列教程]03.给博客添 ... 
- OO博客作业2:第5-7周作业总结
			(1)从多线程的协同和同步控制方面,分析和总结自己三次作业来的设计策略及其变化. 第5次作业:多线程电梯 基本照搬了课件上“生产者-消费者”模型的设计策略,将InputHandler设计为生产者线程, ... 
- 牛客网 Python 编程输入规范
			import sys try: while True: line = sys.stdin.readline().strip() if line == '': break lines = line.sp ... 
- poj2594  机器人寻找宝藏(最小路径覆盖)
			题目来源:http://poj.org/problem?id=2594 参考博客:http://www.cnblogs.com/ka200812/archive/2011/07/31/2122641. ... 
- C#使用OneNote的图片文字识别功能(OCR)
			http://www.cnblogs.com/Charltsing/p/OneNoteOCR.html 有需要技术咨询的,联系QQ564955427 前段时间有人问我能不能通过OneNote扫描图片, ... 
- 书城项目第五阶段---book表的curd
			JavaEE三层架构分析 MVC 
- Vue2.0 搭建Vue脚手架(vue-cli)
			介绍 Vue.js是一套构建用户界面的渐进式框架.Vue 只关注视图层,采用自底向上增量开发的设计.Vue 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件. 阅读之前需要了解的知 ... 
- HTTPS建立连接的过程
			HTTP建立连接的过程点击:HTTP三次握手.一次HTTP请求都发生了什么 一.HTTPS HTTP是超文本传输协议.HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HTTP协议传输隐私 ... 
- SDK安装详解以及adb的来源
			首先,下载Android SDK Tools,翻过墙的朋友可以去Google Android的官网上下载(http://developer.android.com/sdk/index.html) 选择 ... 
- 课程存储校对:程序设计思想、源程序代码、运行结果截图,以及开发过程中的项目计划日志、时间记录日志、缺陷记录日志(PSP0级记录)。
			1.程序设计思想 ⑴将JDBC驱动jar包导入到WEB-INF的lib文件夹下 ⑵建立数据库,在数据库中建表,分别将课程名称.任课教师及上课地点录入到列中 ⑶首先写出加载驱动.关闭资源的工具类和异常处 ... 
