题意:
就是一个圈上有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 ;
}