[并查集]Pku1703--Find them,Catch them

智驾车载以太网(18)-switch之报文转发和vlan处理流程 本文详细解析了交换机中报文处理和转发流程:1)通过目标MAC查找转发端口,源MAC创建ARL条目;2)VLAN标签处理包括tagged/untagged帧判断、默认VID标记等5种处理方式;3)完整转发流程包含CRC校验、IQ封装、VLAN和ARL表查询、端口向量计算及优先级队列发送。文中还涉及TCAM修改VLAN、802.1q多种模式处理等细节,省略了流量控制等次要流程。该过程实现了基于MAC和VLAN的高效二层交换。 阅读详情

http://acm.pku.edu.cn/JudgeOnline/problem?id=1703

 

Find them, Catch them
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 11242 Accepted: 3219

Description

The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which gang a criminal belongs to. The present question is, given two criminals; do they belong to a same clan? You must give your judgment based on incomplete information. (Since the gangsters are always acting secretly.)

Assume N (N <= 10^5) criminals are currently in Tadu City, numbered from 1 to N. And of course, at least one of them belongs to Gang Dragon, and the same for Gang Snake. You will be given M (M <= 10^5) messages in sequence, which are in the following two kinds:

1. D [a] [b]
where [a] and [b] are the numbers of two criminals, and they belong to different gangs.

2. A [a] [b]
where [a] and [b] are the numbers of two criminals. This requires you to decide whether a and b belong to a same gang.

Input

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases. Then T cases follow. Each test case begins with a line with two integers N and M, followed by M lines each containing one message as described above.

Output

For each message "A [a] [b]" in each case, your program should give the judgment based on the information got before. The answers might be one of "In the same gang.", "In different gangs." and "Not sure yet."

Sample Input

1
5 5
A 1 2
D 1 2
A 1 2
D 2 4
A 1 4

Sample Output

Not sure yet.
In different gangs.
In the same gang.

Source

 

 

题目大意:一个城市里有两个帮派,龙帮和蛇帮。现在有n个人,给出以下信息:

D a b:表示a和b不在同一个帮里。

A a b:询问a和b的情况。答案应该是:"In the same gang.", "In different gangs." and "Not sure yet."

 

分析:典型的并查集拓展应用。和Pku1182食物链很类似。对于每个人,由于不知道他是哪个帮的,把他看做是x和x+n两个人,然后并查集以下就搞定了。我一开始狂wa,原因是判断Not sure yet.那里判断错了。其实很简单,只要不是前两种情况,那么就输出not sure yet就行了= =我一开始还开了个数组.....

codes:

 

【原创教程】西门子1500与施耐德伺服的通讯以及调试 该函数块主要描述伺服的手动,左边的引脚Forward是指伺服手动正转,Backward是指伺服手动反转,Fast是指手动的某个方向为快速运行,TipPos手册上描述为固定值,WaitTIme是指伺服手动的相应时间,VeloSlow指伺服手动正常慢速运动的速度,VeloFast指伺服手动快速运动的速度,Acceleration是指伺服手动的加速度,Decelertion是指伺服手动的减速度。该函数块用于伺服停止,左边的引脚Execute为伺服停止执行,Deceleration含义为减速,Axis为轴。 阅读详情

相关推荐

RV1126双摄IMX577驱动移植避坑:从RK3588到RV1126的dts配置与内存崩溃解决实录

本文详细记录了在RV1126平台上移植RK3588的IMX577双摄驱动的完整过程,重点解决了dts配置与内存崩溃问题。通过分析硬件架构差异、驱动移植关键点及CMA内存越界问题,提供了两种有效解决方案,并分享了双摄同步优化与网络调试的实战经验,为嵌入式视觉系统开发提供实用参考。

weixin_42641741的博客 410

Find them, Catch them

The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which g...

qq_40941611的博客 766

Apollo control模块横向控制原理及核心代码逐行解析

看完这篇文章,你会对apollo横向控制有一个整体的概念

weixin_39199083的博客 2万+

poj1703 Find them, Catch them [并查集]

Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23300   Accepted: 6960 Description The police office in Tadu City decides to say ends

smallfish的专栏 396

Qt/C++编写自定义控件42-开关按钮

一、前言 从2010年进入互联网+智能手机时代以来,各种各样的APP大行其道,手机上面的APP有很多流行的元素,开关按钮个人非常喜欢,手机QQ、360卫士、金山毒霸等,都有很多开关控制一些操作,在Qt widgets应用项目上,在项目中应用些类似的开关按钮,估计也会为项目增添不少新鲜感。 总结了大部分的开关按钮控件,基本上有两大类,第一类是纯代码绘制,这种对代码的掌控度要求比较高,但是灵活性比较好...

Qt/C++视频监控/推流/物联网/大屏系统/自定义控件/UI定制/输入法 3335

Gemini-CLI 登录失败?解决报错 This account requires setting the GOOGLE_CLOUD_PROJECT env var 的问题

🚀 刚装好 `gemini-cli` 就遇到登录拦路虎?别慌!本文带你深入解析 `GOOGLE_CLOUD_PROJECT` 环境变量错误的根源,并提供超详细的图文解决方案,让你丝滑开启 AI 命令行之旅!快来抄作业!✍️

XiaoqiangClub的博客 5144

POJ Find them, Catch them

Language: Default Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 33726   Accepted: 10411 Description The police office in Tadu Cit

走一步再走一步 1554

Kriging克里金模型实现数据回归预测Matlab代码

Kriging克里金模型实现数据回归预测Matlab代码

天天酷科研的博客 612

PKU 1703 Find them, Catch them( 并查集的应用)

http://162.105.81.212/JudgeOnline/problem?id=1703题意是有两个集合每次输入D a b 表示a跟b不在一个集合,输入A a b 询问a和b是否在一个集合。以前做过这样的题目(PKU 2492),做法是用一个数组opt[t]存放t的对立,这样每次可以Union(a,opt[b]),Union(b,opt[a]),这样每次可以把相同的类合并。     

834

红米K70至尊版修复“nv损坏”主板电阻图示 mtk芯片工程固件刷写与步骤说明

💝💝💝红米K70至尊版 机型代码:rothko,搭载天玑9300+旗舰芯片.后置5000万像素索尼IMX906高动态OIS主摄,800万像素超广角镜头,200万像素微距镜头,前置2000万像素摄像头,也适用于以下型号的小米机型:2407FPN8EG,2407FPN8ER,XIG06,A402XM,2407FRK8EC。 💝💝💝通过博文了解 1💝💝💝-----此机型工程固件的资源刷写注意事项 2💝💝💝-----此机型刷写工程固件预览界面 3💝💝💝------红米K

小马哥的专栏 1464

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

Android实现TextToSpeech控件实现语音播报--朗读文字 (附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 1131

pku 1703 Find them, Catch them(并查集)

Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24906   Accepted: 7486 Description The police office in Tadu City decides to say ends

街角的花街糖 787

100天精通Oracle-实战系列(第33天)RHEL 7 安装 Oracle 12CR2 RAC 数据库

100天精通Oracle-实战系列(第33天)RHEL 7 安装 Oracle 12CR2 RAC 数据库

LuciferLiu_DBA 3458

pku 1703 Find them, Catch them(并查集)

给节点增加一个域,纪录与父节点的关系,是相同还是不同。#include using namespace std;const int maxn=100005;struct Node{ int parent; bool same;}person[maxn];int Find(int x,bool& same){ same=true; while(pers

low coder 626

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

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

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

POJ1703 Find them, Catch them 【并查集】

Find them, Catch them Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total Submission(s) : 2   Accepted Submission(s) : 1 Problem Description The police office

长风的专栏 1374

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

pku 1703 Find them,Catch them

一般的种类并查集,只不过犯了点小错误,一直TLE View Code #includestdio.h>#includestring.h>int fa[100005],rank[100005],n;void init(){ for(int i=1;in;i++) { fa[i]=i; rank[i]=0; }}int find(int x){

努力奋斗才能梦想成真 650

pku1703 Find them, Catch them

题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1703题意简述:两种操作,A,x,y和D,x,y。分别是问x和y是否属于同一类,和指示x和y是不同类。根据题目的输出来输出相应的返回信息。解题思路:并查集+乱搞。反正我是想着想着就乱搞出来了,在一般的并查集当中加了一个num[i]数组表示与 i 相对的号码。然后就是简单的并查集操作了。

ccsu_001的专栏 698

PKU 1703:Find them, Catch them

并查集

chengdu_zhaihuti的博客 371

PKU1703 find them catch them

<br />         简单的并查集,但是我少打了个句号,于是无数次WA……<br />         并查集里的比较常见的题型,就是记录一个根节点和一个对立根节点。<br /><br />program Find_them_Catch_them; var father,pair:array[0..100000] of longint; n,m,i,t:longint; procedure prework; var i:longint; begin rea

inc(Arthur's fighting) 370

ACM PKU1703 Find them, Catch them

题目描述:http://poj.org/problem?id=1703 这是一道带偏移量的并查集问题,一点点小错误调了我好久,悲剧!奉献代码: #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int MAXN = 100000;...

weixin_30512089的博客 111

POJ 1703 Find them, Catch them

<br />题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1703<br />题目大意:Tadu City里面有两个黑帮团伙Gang Dragon和Gang Snake,一共有n名团伙成员(还不知道属于这两个黑帮的哪一个)。现在警察局有一些信息,每条信息包含2个人编号,表示这2个人属于不同的帮派。问给你2个人的编号,能否确定他们是否属于同一个帮派。<br />题目分析:并查集。用opp[x]表示和x属于不同黑帮的一个成员编号,只需要知道一个就可以了,因为

liujun90214的专栏 483

Find them, Catch them(并查集的变形)

感觉这个题很神奇,刚开始以为自己看懂了,但是后来却发现自己没懂的地方好多,运用了很多巧妙的地方,两种很好的方法供参考(很好的并查集的变形) 1.他是两个并查集之间的变化,两种方法第一种,将所有的情况两个集合的所有及节点合并到一个并查集中,通过数组rel表示与根节点或者父节点是否相同的问题,第二种,一个集合一个并查集,通过结构体保存他的对立面的根节点,通过判断确定是否是一个集合 2.若是第一种方

yinghui_yht的博客 2028

Find them, Catch them -种类并查

Find them, Catch them  POJ - 1703  #include&lt;stdio.h&gt; #include&lt;cstring&gt; using namespace std; #define maxn 2222 int n,m,x,y,T; struct node { int pos,same; } xre,yre; int fa[maxn...

BePosit的博客 629

Find them, Catch them - 并查集

The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which g...

m0_37579232的博客 1410

Find them, Catch them(带权值的并查集)

Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 44642 Accepted: 13751DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to roo...

我和我的三只猫 528

POJ 1703 Find them, Catch them

种类并查集!!! 这里使用的两段区间求法!!两种种类并查集比较好理解,就是和你不同类的两个就是同类!! 表情分界线 AC代码如下: #include #include #include #include #include #include #define inf 2000000000 #define linf 1000000000000000000LL #d

墨守空城与钟楼 939
上一篇: [动态规划]Pku1160--Post Office
下一篇: [动态规划]Pku3377--Ferry Lanes
fstephen
博客等级 码龄18年 7粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值