Contest - 多校训练(三)
Problem B: H
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 282 Solved: 118
SubmitStatusWeb Board
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
131 1 11 2 11 1 1
Sample Output
yes
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{int t,n,x,y,z;
scanf("%d",&t);
while(t--)
{scanf("%d",&n);
map<string,int>q;
char ch[4];
q.clear();
int f=0;
for(int i=0;i<n;i++)
{scanf("%d%d%d",&x,&y,&z);
ch[0]=x+'0';
ch[1]=y+'0';
ch[2]=z+'0';
ch[3]='\0';
if(q[ch]!=0)
f=1;
else
q[ch]++;
}
if(f==1)
printf("yes\n");
else
printf("no\n");
}
}
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{int t,n,x,y,z;
scanf("%d",&t);
while(t--)
{scanf("%d",&n);
map<string,int>q;
char ch[4];
q.clear();
int f=0;
for(int i=0;i<n;i++)
{scanf("%d%d%d",&x,&y,&z);
ch[0]=x+'0';
ch[1]=y+'0';
ch[2]=z+'0';
ch[3]='\0';
if(q[ch]!=0)
f=1;
else
q[ch]++;
}
if(f==1)
printf("yes\n");
else
printf("no\n");
}
}