题解:

解法一:建立图论模型,发现只要联通块中有环则这个联通块中的值都可以被攻击到

如果是树,则只能攻击size-1个

解法二:二分图匹配,二分答案,看看是否能攻击到mid

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int u=10000; int n; int father[u+1];
int isinc[u+1];
int siz[u+1];
int Getf(int x){
if(father[x]==x)return x;
return father[x]=Getf(father[x]);
}
void Unionn(int x,int y){
int fx=Getf(x);
int fy=Getf(y);
if(fx!=fy){
father[fx]=fy;
siz[fy]+=siz[fx];
isinc[fy]=isinc[fy]|isinc[fx];
}
} int main(){
for(int i=1;i<=u;++i)father[i]=i;
for(int i=1;i<=u;++i)siz[i]=1;
scanf("%d",&n);
while(n--){
int x,y;
scanf("%d%d",&x,&y);
if(Getf(x)==Getf(y)){
isinc[Getf(x)]=1;
}else{
Unionn(x,y);
}
} for(int i=1;i<=u;++i){
int f=Getf(i);
if(isinc[f])continue;
if(siz[f]==1){
printf("%d\n",i-1);
return 0;
}
--siz[f];
}
printf("%d\n",u);
return 0;
}

  

BZOJ [Scoi2010]游戏的更多相关文章

  1. BZOJ 1854: [Scoi2010]游戏 无向图判环

    题目链接: 题目 1854: [Scoi2010]游戏 Time Limit: 5 Sec Memory Limit: 162 MB 问题描述 lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装 ...

  2. BZOJ 1854: [Scoi2010]游戏( 二分图最大匹配 )

    匈牙利算法..从1~10000依次找增广路, 找不到就停止, 输出答案. --------------------------------------------------------------- ...

  3. 【BZOJ】1854: [Scoi2010]游戏【二分图】

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 6759  Solved: 2812[Submit][Status] ...

  4. BZOJ 1854: [Scoi2010]游戏 并查集

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 2672  Solved: 958[Submit][Status][ ...

  5. AC日记——[SCOI2010]游戏 bzoj 1854

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 4938  Solved: 1948[Submit][Status] ...

  6. 1854: [Scoi2010]游戏

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 2538  Solved: 905[Submit][Status] ...

  7. 【BZOJ1854】[Scoi2010]游戏 二分图最大匹配

    [BZOJ1854][Scoi2010]游戏 Description lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当 ...

  8. bzoj1854 [Scoi2010]游戏 ([SCOI2010]连续攻击游戏)

    bzoj1854 [Scoi2010]游戏 ([SCOI2010]连续攻击游戏) 据说正解是并查集???我不会 这不是一道匈♂牙利好题吗??? 一个装备的两个属性都向它连边,然后跑一遍匈♂牙利 注意: ...

  9. 1854: [Scoi2010]游戏[并查集]

    1854: [Scoi2010]游戏 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 4938  Solved: 1948[Submit][Status] ...

随机推荐

  1. 微信小程序-发送模板消息

    1 添加一个小程序的消息模板,获取到模板id,存储到数据库中,方便以后修改调用 2. https://developers.weixin.qq.com/miniprogram/dev/api-back ...

  2. 061、Java中利用return结束方法调用

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  3. leetcode1305 All Elements in Two Binary Search Trees

    """ Given two binary search trees root1 and root2. Return a list containing all the i ...

  4. 启动Eureka出现错误:Archive for required library in project cannot be read or is not a valid ZIP file

    To fix issues like that, let Maven download the files again: Delete the folder D:/mypath/.m2/reposit ...

  5. LeetCode160 相交链表(双指针)

    题目: click here!!题目传送门 思路: 1.笨方法 因为如果两个链表相交的话,从相交的地方往后是同一条链表,所以: 分别遍历两个链表,得出两个链表的长度,两个长度做差得到n,然后将长的链表 ...

  6. P1011 A+B 和 C

    转跳点:

  7. Ajax学习系列——创建XMLHttpRequest对象

    Ajax - 创建XMLHttpRequest对象 首先介绍什么是XMLHttpRequest: XMLHttpRequest是Ajax的基础.中文可以解释为可扩展超文本传输请求.术语缩写为XHR. ...

  8. laravel.01.一些细节

    0:参考1,参考2,参考3,参考4,参考5 1.读取项目的配置文件内容,比如app.php下的name属性,用config('app.name','default-value'); 2.读取.ENV文 ...

  9. ServletContext 详解

    ServletContext——它是一个全局的储存信息的空间,服务器开始,其就存在,服务器关闭,其才释放.request,一个用户可有多个:session,一个用户一个:而servletContext ...

  10. 【剑指Offer】面试题09. 用两个栈实现队列

    题目 用两个栈实现一个队列.队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能.(若队列中没有元素,delete ...