摘要: 通过数据要判断俩点: 1、要保证每个点都相通,2、两点之间只有一条路径相通 方法: 1、判断连通图,即ans#include #define N 100001struct d{ int x; int y;}buf[N];int flag;int parent[N];bool judge[N];i... 阅读全文
posted @ 2015-12-19 15:40 StevenLuke 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 为啥ans要 -1 ? 未解。 #include #define N 1000struct d{ int x; int y;}buf[N];int parent[N];int find(int x) { return x==parent[x] ? x : find(parent[x]);}voi... 阅读全文
posted @ 2015-12-19 14:53 StevenLuke 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 并查集 for(i=0; i#define N 1001struct d{ int x; int y;}buf[N];int parent[N];int find(int x) { return x==parent[x] ? x : find(parent[x]);}void uni(int x... 阅读全文
posted @ 2015-12-19 14:28 StevenLuke 阅读(97) 评论(0) 推荐(0) 编辑