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',那么两条线段如果必须一 ...
随机推荐
- 1003: [ZJOI2006]物流运输 = DP+SBFA
题意就是告诉你有n个点,e条边,m天,每天都会从起点到终点走一次最短路,但是有些点在某些时间段是不可走的,因此在某些天需要改变路径,每次改变路径的成本是K,总成本=n天运输路线长度之和+K*改变运输路 ...
- Applese 的毒气炸弹 G 牛客寒假算法基础集训营4(图论+最小生成树)
链接:https://ac.nowcoder.com/acm/contest/330/G来源:牛客网 Applese 的毒气炸弹 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262 ...
- 使用HDTune规避硬盘上损坏的扇区
如何使用HDTune扫描磁盘上的错误在网上已经有很多帖子了,但扫描到之后如何用HDTune来规避硬盘上损坏的扇区呢? HDTune并不能直接规避,而是需要重新划分磁盘的卷.HDTune一行有50个小方 ...
- Python爬虫——用BeautifulSoup、python-docx爬取廖雪峰大大的教程为word文档
版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com 廖雪峰大大贡献的教程写的不错,写了个爬虫把教程保存为word文件,供大家方便下载学习:http://p ...
- 同事写得Python对页面压测脚本
#!/usr/bin/env python # *-* coding:utf-8 *-* import threading import requests import time # headers ...
- Java 里如何实现线程间通信(转载)
出处:http://www.importnew.com/26850.html 正常情况下,每个子线程完成各自的任务就可以结束了.不过有的时候,我们希望多个线程协同工作来完成某个任务,这时就涉及到了线程 ...
- JS --- 如何获取一个对象的类型
可以清楚的看到 拿到数字 字符串 对象 函数 数组 通过.slice(8,-1) 可以拿到类型的名称 ,可以做你想要的操作 Object.prototype.toString.call(222) & ...
- rem 自适应、整体缩放
html{ font-size: calc(100vw/7.5); } 说明: 100vw是设备的宽度,除以7.5可以让1rem的大小在iPhone6下等于100px. 若是低版本的设备不支持rem, ...
- element-ui 源码解析 一
Button组件 button.vue <template> <button class="el-button" @click="handleClick ...
- Partition算法以及其应用详解下(Golang实现)
接前文,除了广泛使用在快速排序中.Partition算法还可以很容易的实现在无序序列中使用O(n)的时间复杂度查找kth(第k大(小)的数). 同样根据二分的思想,每完成一次Partition我们可以 ...