POJ 1703

Find them, Catch them
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 46068 Accepted: 14176

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.

解题思路:一道并查集的题目,但是有点不一样,就是那个D,描述的是不同的,想了好久不知道如何处理,看了下别人的解题报告

有些地方还是不理解,以后有时间再看看!

#include<stdio.h>

int father[150500],relation[150050];

void init(int n)
  {
     int i;
     for(i=1;i<=n;++i) father[i]=i;
     for(i=1;i<=n;++i) relation[i]=0;
  }
  
int find(int x)
  {
     int t;
     if(x==father[x]) return (x);
     t=father[x];
     father[x]=find(t);
     relation[x]=(relation[x]+relation[t])%2;
     return (father[x]);
  }
  
void merge(int x,int y)
  {
     int find_x=find(x);
     int find_y=find(y);
     if(find_x!=find_y)
       {
          relation[find_x]=(relation[y]+1-relation[x]+2)%2;
          father[find_x]=find_y;
       }
  }
  
int main()
  {
     int T,n,m,num=0;char c;int x,y;
     scanf("%d",&T);
     while(T--)
       {
          scanf("%d%d",&n,&m);
          init(n);
          while(m--)
            {
              getchar();
              scanf("%c%d%d",&c,&x,&y);
              if(c=='D')
                {
                   merge(x,y);
                }else
              if(c=='A')
                {
                  if(find(x)!=find(y))
                    {
                       printf("Not sure yet.\n");
                       continue;
                    }else
                  if(relation[x]==relation[y])
                    {
                       printf("In the same gang.\n");
                       continue;
                    }else
                  if(relation[x]!=relation[y])
                    printf("In different gangs.\n");
                }
            }
       }
     return 0;
  }


内容概要:本文档介绍了基于3D FDTD(时域有限差分)方法在MATLAB平台上对微带线馈电的矩形天线进行仿真分析的技术方案,重点在于模拟超MATLAB基于3D FDTD的微带线馈矩形天线分析[用于模拟超宽带脉冲通过线馈矩形天线的传播,以计算微带结构的回波损耗参数]宽带脉冲信号通过天线结构的传播过程,并计算微带结构的回波损耗参数(S11),以评估天线的匹配性能和辐射特性。该方法通过建立三维电磁场模型,精确求解麦克斯韦方程组,适用于高频电磁仿真,能够有效分析天线在宽频带内的响应特性。文档还提及该资源属于一个涵盖多个科研方向的综合性MATLAB仿真资源包,涉及通信、信号处理、电力系统、机器学习等多个领域。; 适合人群:具备电磁场与微波技术基础知识,熟悉MATLAB编程及数值仿真的高校研究生、科研人员及通信工程领域技术人员。; 使用场景及目标:① 掌握3D FDTD方法在天线仿真中的具体实现流程;② 分析微带天线的回波损耗特性,优化天线设计参数以提升宽带匹配性能;③ 学习复杂电磁问题的数值建模与仿真技巧,拓展在射频与无线通信领域的研究能力。; 阅读建议:建议读者结合电磁理论基础,仔细理解FDTD算法的离散化过程和边界条件设置,运行并调试提供的MATLAB代码,通过调整天线几何尺寸和材料参数观察回波损耗曲线的变化,从而深入掌握仿真原理与工程应用方法。
内容概要:本文系统介绍了无人机测绘在多个领域的广泛应用,重点阐述了其在基础地理信息测绘、工程建设、自然资源与生态环境监测、农业与农村管理、应急救灾以及城市管理等方面的实践价值。无人机凭借灵活作业、低成本、高精度和快速响应的优势,结合航测相机、LiDAR、多光谱、热成像等多种传感器,能够高效获取DOM、DSM、DEM、DLG等关键地理数据,并生成三维模型,显著提升测绘效率与精度,尤其适用于复杂地形和紧急场景。文章还强调了无人机在不同时期工程项目中的动态监测能力及在生态环保、土地确权、灾害应急等方面的数据支撑作用。; 适合人群:从事测绘、地理信息系统(GIS)、城乡规划、自然资源管理、农业信息化、应急管理等相关工作的技术人员与管理人员;具备一定地理信息基础知识的专业人员;无人机应用从业者或爱好者。; 使用场景及目标:①了解无人机测绘的技术优势及其在各行业中的具体应用场景;②为实际项目中选择合适的无人机测绘方案提供参考依据;③支持政府部门、企事业单位在土地管理、工程建设、灾害应对等领域实现数字化、智能化决策。; 阅读建议:此资源以应用为导向,涵盖了技术原理与实践案例,建议结合具体业务需求深入研读,并可进一步索取“无人机测绘设备选型与作业流程清单”以指导实际操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值