题意:

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

解析:

  我手残 我手残 我手残

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

即一个1一个0

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <sstream>
  4. #include <cstring>
  5. #include <map>
  6. #include <cctype>
  7. #include <set>
  8. #include <vector>
  9. #include <stack>
  10. #include <queue>
  11. #include <algorithm>
  12. #include <cmath>
  13. #include <bitset>
  14. #define rap(i, a, n) for(int i=a; i<=n; i++)
  15. #define rep(i, a, n) for(int i=a; i<n; i++)
  16. #define lap(i, a, n) for(int i=n; i>=a; i--)
  17. #define lep(i, a, n) for(int i=n; i>a; i--)
  18. #define rd(a) scanf("%d", &a)
  19. #define rlld(a) scanf("%lld", &a)
  20. #define rc(a) scanf("%c", &a)
  21. #define rs(a) scanf("%s", a)
  22. #define pd(a) printf("%d\n", a);
  23. #define plld(a) printf("%lld\n", a);
  24. #define pc(a) printf("%c\n", a);
  25. #define ps(a) printf("%s\n", a);
  26. #define MOD 2018
  27. #define LL long long
  28. #define ULL unsigned long long
  29. #define Pair pair<int, int>
  30. #define mem(a, b) memset(a, b, sizeof(a))
  31. #define _ ios_base::sync_with_stdio(0),cin.tie(0)
  32. //freopen("1.txt", "r", stdin);
  33. using namespace std;
  34. const int maxn = 1e5 + , INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff;
  35. int n, m;
  36. int sccno[maxn], vis[maxn], low[maxn], scc_cnt, scc_clock;
  37. stack<int> S;
  38. vector<int> G[maxn];
  39. struct node
  40. {
  41. int x, y;
  42. }Node[maxn];
  43.  
  44. void init()
  45. {
  46. mem(sccno, );
  47. mem(vis, );
  48. mem(low, );
  49. for(int i = ; i < maxn; i++) G[i].clear();
  50. scc_cnt = scc_clock = ;
  51. }
  52.  
  53. void dfs(int u)
  54. {
  55. low[u] = vis[u] = ++scc_clock;
  56. S.push(u);
  57. for(int i = ; i < G[u].size(); i++)
  58. {
  59. int v = G[u][i];
  60. if(!vis[v])
  61. {
  62. dfs(v);
  63. low[u] = min(low[u], low[v]);
  64. }
  65. else if(!sccno[v])
  66. low[u] = min(low[u], vis[v]);
  67. }
  68. if(vis[u] == low[u])
  69. {
  70. scc_cnt++;
  71. for(;;)
  72. {
  73. int x = S.top(); S.pop();
  74. sccno[x] = scc_cnt;
  75. if(x == u) break;
  76. }
  77. }
  78. }
  79.  
  80. bool check()
  81. {
  82. for(int i = ; i < n * ; i += )
  83. if(sccno[i] == sccno[i^])
  84. return false;
  85. return true;
  86. }
  87.  
  88. int main()
  89. {
  90. init();
  91. cin >> n >> m;
  92. for(int i = ; i < m; i++)
  93. {
  94. cin >> Node[i].x >> Node[i].y;
  95. }
  96. for(int i = ; i < m; i++)
  97. {
  98. for(int j = i + ; j < m; j++)
  99. {
  100. int x1 = Node[i].x, y1 = Node[i].y, x2 = Node[j].x, y2 = Node[j].y;
  101. if(x1 > y1) swap(x1, y1);
  102. if(x2 > y2) swap(x2, y2);
  103. 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)
  104. {
  105. G[i << | ].push_back(j << );
  106. G[j << ].push_back(i << | );
  107. G[j << | ].push_back(i << );
  108. G[i << ].push_back(j << | );
  109. }
  110. }
  111. }
  112. for(int i = ; i < n * ; i++)
  113. if(!vis[i]) dfs(i);
  114. if(check()) cout << "panda is telling the truth..." << endl;
  115. else cout << "the evil panda is lying again" << endl;
  116.  
  117. return ;
  118. }

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. 1003: [ZJOI2006]物流运输 = DP+SBFA

    题意就是告诉你有n个点,e条边,m天,每天都会从起点到终点走一次最短路,但是有些点在某些时间段是不可走的,因此在某些天需要改变路径,每次改变路径的成本是K,总成本=n天运输路线长度之和+K*改变运输路 ...

  2. Applese 的毒气炸弹 G 牛客寒假算法基础集训营4(图论+最小生成树)

    链接:https://ac.nowcoder.com/acm/contest/330/G来源:牛客网 Applese 的毒气炸弹 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262 ...

  3. 使用HDTune规避硬盘上损坏的扇区

    如何使用HDTune扫描磁盘上的错误在网上已经有很多帖子了,但扫描到之后如何用HDTune来规避硬盘上损坏的扇区呢? HDTune并不能直接规避,而是需要重新划分磁盘的卷.HDTune一行有50个小方 ...

  4. Python爬虫——用BeautifulSoup、python-docx爬取廖雪峰大大的教程为word文档

    版权声明:本文为博主原创文章,欢迎转载,并请注明出处.联系方式:460356155@qq.com 廖雪峰大大贡献的教程写的不错,写了个爬虫把教程保存为word文件,供大家方便下载学习:http://p ...

  5. 同事写得Python对页面压测脚本

    #!/usr/bin/env python # *-* coding:utf-8 *-* import threading import requests import time # headers ...

  6. Java 里如何实现线程间通信(转载)

    出处:http://www.importnew.com/26850.html 正常情况下,每个子线程完成各自的任务就可以结束了.不过有的时候,我们希望多个线程协同工作来完成某个任务,这时就涉及到了线程 ...

  7. JS --- 如何获取一个对象的类型

    可以清楚的看到  拿到数字 字符串 对象 函数 数组 通过.slice(8,-1) 可以拿到类型的名称 ,可以做你想要的操作 Object.prototype.toString.call(222) & ...

  8. rem 自适应、整体缩放

    html{ font-size: calc(100vw/7.5); } 说明: 100vw是设备的宽度,除以7.5可以让1rem的大小在iPhone6下等于100px. 若是低版本的设备不支持rem, ...

  9. element-ui 源码解析 一

    Button组件 button.vue <template> <button class="el-button" @click="handleClick ...

  10. Partition算法以及其应用详解下(Golang实现)

    接前文,除了广泛使用在快速排序中.Partition算法还可以很容易的实现在无序序列中使用O(n)的时间复杂度查找kth(第k大(小)的数). 同样根据二分的思想,每完成一次Partition我们可以 ...