zzulioj1915:查找重复点

Description

在三维空间里,晴天得到了一些坐标,然后他想知道这些坐标有没有重合的哇,然后若两个坐标是重合的也就是x=x,y=y,z=z。然后他把这个任务交给你啦。

Input

输入第一行包含一个整数t表示有多少组数据。
每组数据一个整数n,表示有多少个点。
接下来n行,每行有三个整数x,y,z表示一个点的坐标.
0<=n<=200000,0<=x,y,z<100,t<=20

Output


若有两个点重合输出yes,否则输出no

Sample Input

1
3
1 1 1
1 2 1
1 1 1

Sample Output

yes

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
	int x,y,z;
}dian[200001];
bool cmp(node a,node b )
{
	if(a.x!=b.x )
	{
			return a.x <b.x ;
	}
	else
	{
	  if(a.y !=b.y )
	  {
	  	return a.y <b.y;
	  }
    	else
	   {
		return a.z <b.z ; 
    	}
	 } 

}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d%d%d",&dian[i].x ,&dian[i].y ,&dian[i].z );
		}
		sort(dian,dian+n,cmp);
		int cnt=0;//每个区间的起点 
	     int sum=0;
		for(int i=1;i<n;i++)
		{
			if(dian[i].x ==dian[cnt].x &&dian[i].y ==dian[cnt].y &&dian[i].z ==dian[cnt].z )
			{
				sum=1;
				break;
			}
			else
			{
				cnt=i;//更新起点 
			}
		}
		if(sum==1)
		printf("yes
");
		else
		printf("no
");
	}
	return 0;
}



原文地址:https://www.cnblogs.com/kingjordan/p/12027050.html