HDU 2120 Ice_cream's world I(并查集)

【SCADA】KingSCADA将数据插入SQLServer的方法 1、创建数据库及数据表格;2、配置ODBC数据源。3、通过KingSCADA与数据库建立连接,将数据写入数据库对应表格。 阅读详情

题目地址:HDU 2120

这题虽然字数不多,但就是看不懂。。意思是求最多有多少个被墙围起来的区域。显然就是求环的个数。然后用并查集求环个数就可以了。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
int bin[2000];
int find1(int x)
{
    return bin[x]==x?x:bin[x]=find1(bin[x]);
}
int main()
{
    int n, m, ans, a, b, f1, f2, i;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        ans=0;
        for(i=0;i<n;i++)
            bin[i]=i;
        while(m--)
        {
            scanf("%d%d",&a,&b);
            f1=find1(bin[a]);
            f2=find1(bin[b]);
            if(f1==f2)
                ans++;
            else
                bin[f2]=f1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Simulink仿真入门到精通(三) Simulink信号 本系列教程是根据孙忠潇编著的<<Simulink仿真及代码生成技术入门到精通>>学习笔记。 目录 Simulink仿真入门到精通(一) Simulink界面介绍 Simulink仿真入门到精通(二) Simulink模块 Simulink仿真入门到精通(三) Simulink信号 Simulink仿真入门到精通(四) Simulink子系统 Simulink仿真入门到精通(五) Simulink模型的仿真 Simulink仿真入门到精通(六) Simulink模型保存为图片 Sim 阅读详情

相关推荐

VMware桥接模式实战:用手机热点给Linux虚拟机共享网络(附WiFi适配技巧)

本文详细介绍了在移动办公场景下,如何为VMware中的Linux虚拟机配置桥接模式,以通过手机热点共享网络。文章深入解析了桥接模式在无线环境下的工作原理,提供了从主机端准备、VMware设置到Linux虚拟机内部配置的完整实战步骤,并针对手机热点的特殊性,分享了MTU优化、DNS配置及常见网络问题的诊断与解决方案,帮助用户实现稳定高效的移动虚拟化办公。

2y3u4i5o6p的博客 1219

G - Ice_cream's world I 【hdu 2120 并查集】

题目链接 Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1746    Accepted Submission(s): 1016 Problem Description ic

hubayi31072的博客 347

手把手教你用mitmproxy抓包抖音数据流(附Python脚本模板)

本文详细介绍了如何使用mitmproxy抓包抖音数据流,包括环境搭建、证书安装和Python脚本模板。从mitmproxy配置到抖音API解析,提供完整的移动端数据流分析方案,帮助开发者快速掌握数据抓取技术,适用于应用优化、竞品分析和安全审计等场景。

weixin_33670786的博客 313

HDU2120Ice_cream's world I(基础并查集)

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 698    Accepted Submission(s): 398 Problem Description ice_cream's

青山绿水之辈 专栏 1056

Proteus下载安装快速入门:30分钟掌握全过程

手把手教你完成proteus下载安装,从环境配置到首次运行一气呵成,适合电子设计新手快速掌握仿真工具的核心操作步骤。

weixin_31974443的博客 905

【GNSS测试技术(一)】GNSS基础原理介绍

GNSS(全球卫星导航系统)是一种基于卫星信号的定位技术,通过使用分布在地球轨道上的卫星,为用户提供全球范围内的定位、导航和授时服务。

新猿异码的博客 5775

HDU Problem 2120 Ice_cream's world I 【并查集检查环】

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1193    Accepted Submission(s): 716 Problem Description ice_cre

博客已搬迁到http://www.cnblogs.com/cniwoq/ 342

Overleaf-Latex-Elsevier-图、表、参考文献标题及引用、伪代码写法(绝对详细直观且易懂)

overleaf爱思唯尔模板踩过的一些坑以及解决办法

2403_87584552的博客 5861

HDU 2120 Ice_cream's world I (并查集判环)

Description: ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall bet...

邵光亮的博客 690

基于Ultralytic实现多路摄像头目标检测

基于Ultralytic实现多路摄像头目标检测前面的文章分享了单路摄像头画面的YOLO目标检测,这篇文章主要分享一下多路摄像头画面的实时YOLO目标检测。测试环境在Windows系统下进行。

qq_57674776的博客 950

python点云可视化

Python三种点云可视化方案:mayavi、matplotlib、CloudCompare。

叶子的博客 1万+

hdu 2120 Ice_cream's world I 并查集

题目链接 题意:给出n个哨塔,m面墙。被墙围起来的土地可以分给一个人。问一共可以分给多少人土地。 这题的求的是图中环的个数。用并查集来做,读入两个点,当这两个点的父节点相同说明这两个点已经连通,这时候再加上这条边就形成了一个环。以此来统计环的个数。 #include #include #include #include using namespace std; int ans,pre[

弱菜zc 912

大语言模型原理与工程实践:手把手教你训练 7B 大语言模型 自动化训练框架

近年来,大语言模型(Large Language Models,LLMs)在自然语言处理领域取得了突破性进展。从GPT-3到ChatGPT,再到最新的GPT-4,这些模型展现出了惊人的语言理解和生成能力,引发了学术界和产业界的广泛关注。然而,训练如此庞大的模型不仅需要海量的数据和计算资源,还需要复杂的工程实践和优化技巧。本文将深入探讨大语言模型的原理,并以7B参数规模的模型为例,详细介绍如何构建一个自动化训练框架,使读者能够亲自动手训练自己的大语言模型。

AI天才研究院 1928

HDU 2120 Ice_cream's world I 并查集

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1138 Accepted Submission(s): 684 Problem Description ice_cream's world is

Warren's Blog 490

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Ice_cream's world I hdu 2120 并查集判断环

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 483    Accepted Submission(s): 262 Problem Description ice_crea

风华绝代 1112

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Ice_cream's world I HDU - 2120 (并查集判断环)

Problem Description ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and w...

Jin_Yanhui 181

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Ice_cream's world I HDU - 2120(并查集判环)

题意:问给出的望塔之间的建造了围墙,将土地分成了几份 思路:用并查集判环,若有围墙相接的瞭望塔,有相同的父根,则存在环 ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So ther...

zeng_jun_yv的博客 211

Ice_cream's world I HDU - 2120(并查集,求环数)

Problem Description ice_cream’s world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wal...

我の名字 266

HDU 2120Ice_cream's world I(并查集+环)

Description ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall betwe

菜鸟的自我修养 269

HDU 2120 Ice_cream's world I(并查集,环的个数,冰激凌王国有什么?)

Ice_cream's world I(题目) Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1254    Accepted Submission(s): 750 Problem Description ice

Shyazhut 438

【HDU2120】Ice_cream's world I(并查集基础题)

查环操作,裸题。一次AC。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cctype> 5 #include <cmath> 6 #include <string> 7 #...

banxuanliu0005的博客 112

HDU 2120--Ice_cream's world I【并查集, 判断环的个数】

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 783    Accepted Submission(s): 458 Problem Description ice_cream's

_阿阿阿阿欢 612

HDU 2120 Ice_cream's world I【并查集】

解题思路:给出n对点的关系,求构成多少个环,如果对于点x和点y,它们本身就有一堵墙,即为它们本身就相连,如果find(x)=find(y),说明它们的根节点相同,它们之间肯定有直接或间接的相连,即形成环 样例的示意图 共3个环 Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 3276...

weixin_30569001的博客 84

【HDU】-2120-Ice_cream's world I(并查集,环)

Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1235    Accepted Submission(s): 743 Problem Description ice_cre

Bear1998的博客 390

HDU - 2120 Ice_cream's world I(并查集判断环的存在)

题目链接:https://cn.vjudge.net/contest/320541#problem/B 翻译:给定几组关系,求是否能构成环,求构成环的个数。 分析:构成环的条件,a,b有相同的祖先,a能直接到祖先,也能通过b找到祖先,所以能构成环。 代码: #include<cstdio> #include<cstring> int n,m,f[1001]; int get...

zaiyang遇见 241

hdu杭电2120 Ice_cream's world I【并查集】

Problem Description ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wa

Determined&Diligent的专栏 409
上一篇: HDU 1856 More is better(并查集+离散化)
下一篇: HDU 1829 && POJ 2492 A Bug's Life(种类并查集)
Aerolite坠落
博客等级 码龄13年 203粉丝 640原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值