摘要: 题意:http://codeforces.com/problemset/problem/456/E 思路: 并查集被坑到了,得用路径压缩。 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//spr 阅读全文
posted @ 2020-03-28 19:57 ZMWLxh 阅读(314) 评论(0) 推荐(0) 编辑
摘要: 题意:http://codeforces.com/problemset/problem/456/D 两个人玩游戏。游戏是拼单词,给出了一个含有n个单词的词库。当前单词初始为空,每个人轮流给它末尾加一个字母,要求当前单词是词库中任意一个词的前缀,当某个人不能加字母了他就输。这个游戏重复k局,一局输的人 阅读全文
posted @ 2020-03-28 19:55 ZMWLxh 阅读(348) 评论(0) 推荐(0) 编辑
摘要: int Find(int xa){ int xb=xa; //把初始值赋给b while(xa!=fa[xa]){ xa=fa[xa]; //找到a的祖先节点 } while(xb!=xa){ //直到b==a为止 int temp=fa[xb]; //设一个中间变量为b的父亲节点 fa[xb]=x 阅读全文
posted @ 2020-03-28 17:42 ZMWLxh 阅读(199) 评论(0) 推荐(0) 编辑