LightOJ 1410 - Consistent Verdicts (判断去重)
来源:互联网 发布:陶泽如 知乎 编辑:程序博客网 时间:2024/04/29 11:49
1410 - Consistent Verdicts
Description
In a 2D plane N persons are standing and each of them has a gun in his hand. The plane is so big that the persons can be considered as points and their locations are given as Cartesian coordinates. Each of theN persons fire the gun in his hand exactly once and no two of them fire at the same or similar time (the sound of two gun shots are never heard at the same time by anyone so no sound is missed due to concurrency). The hearing ability of all these persons is exactly same. That means if one person can hear a sound at distanceR1, so can every other person and if one person cannot hear a sound at distanceR2 the other N-1 persons cannot hear a sound at distanceR2 as well.
The N persons are numbered from 1 to N. After all the guns are fired, all of them are asked how many gun shots they have heard (not including their own shot) and they give their verdict. It is not possible for you to determine whether their verdicts are true but it is possible for you to judge if their verdicts are consistent. For example, look at the figure above. There are five persons and their coordinates are (1, 2), (3, 1), (5, 1), (6, 3) and (1, 5) and they are numbered as 1, 2, 3, 4 and 5 respectively. After all five of them have shot their guns, you ask them how many shots each of them have heard. Now if there response is 1, 1, 1, 2 and 1 respectively then you can represent it as (1, 1, 1, 2, 1). But this is an inconsistent verdict because if person 4 hears 2 shots then he must have heard the shot fired by person 2, then obviously person 2 must have heard the shot fired by person 1, 3 and 4 (person 1 and 3 are nearer to person 2 than person 4). But their opinions show that Person 2 says that he has heard only 1 shot. On the other hand (1, 2, 2, 1, 0) is a consistent verdict for this scenario so is (2, 2, 2, 1, 1). In this scenario (5, 5, 5, 4, 4) is not a consistent verdict because a person can hear at most 4 shots.
Given the locations of N persons, your job is to find the total number of different consistent verdicts for that scenario. Two verdicts are different if opinion of at least one person is different.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing a positive integer N (1 ≤ N ≤ 700). Each of the nextN lines contains two integers xi yi (0 ≤ xi, yi ≤ 30000) denoting a co-ordinate of a person. Assume that all the co-ordinates are distinct.
Output
For each case, print the case number and the total number of different consistent verdicts for the given scenario.
Sample Input
2
3
1 1
2 2
4 4
2
1 1
5 5
Sample Output
Case 1: 4
Case 2: 2
把每两个点之间的距离求出来,然后去重然后+1即为所求
ac代码:
#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#define MAXN 1010000#define MOD 1000000007#define LL long long#define INF 0xfffffff#define fab(a)(a)>0?(a):(-a)using namespace std;struct s{int x;int y;}a[MAXN];double dis[MAXN];double fun(int aa,int bb){return sqrt((a[aa].x-a[bb].x)*(a[aa].x-a[bb].x)+(a[aa].y-a[bb].y)*(a[aa].y-a[bb].y));}int main(){int t,i,n,j;int cas=0;scanf("%d",&t);while(t--){scanf("%d",&n);for(i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);int k=0;for(i=1;i<=n;i++){for(j=i+1;j<=n;j++){dis[k++]=fun(i,j);}}sort(dis,dis+k);double v=dis[0];int ans=1;for(i=1;i<k;i++){if(dis[i]!=v)ans++,v=dis[i];}printf("Case %d: %d\n",++cas,ans+1);} return 0;}
- LightOJ 1410 - Consistent Verdicts (判断去重)
- LightOj 1410 - Consistent Verdicts
- LightOJ 1410 - Consistent Verdicts
- lightoj Consistent Verdicts 1410 (距离计算)
- 【LightOJ】1410 - Consistent Verdicts(思维)
- lightoj 1410 - Consistent Verdicts 【思维】
- lightoj--1410--Consistent Verdicts(技巧)
- LIGHTOJ 1410 - Consistent Verdicts【SET】
- lightoj-1410-Consistent Verdicts【思维】
- lightoj 1410 - Consistent Verdicts1410 - Consistent Verdicts
- Light OJ 1410 - Consistent Verdicts 【排序去重】
- Consistent Verdicts坐标--去重-code force1410
- lightoj-【Consistent Verdicts】
- 【Light-OJ】-1410- Consistent Verdicts(思维)
- 【1410 - Consistent Verdicts】+ 思维
- light oj 1410 - Consistent Verdicts
- Light OJ-----1410---Consistent Verdicts
- light1410 - Consistent Verdicts
- int short long 在不同环境下字节数
- HttpClient 讲解 (2) 项目封装
- 程序员的支配力 (上)
- 树形dp
- 数据库大数据访问的解决方法
- LightOJ 1410 - Consistent Verdicts (判断去重)
- ubuntu在系统启动无法进入桌面的处理方法
- MediaPlayer的使用
- UITextView 获取键盘的发送事件
- Node.js实践HTTP安全认证之三~~摘要认证(实践)
- linux新增特性timerfd
- php发送get、post请求的几种方法
- 二叉树的建立和遍历(递归、非递归)
- <仅是自己做笔记。。。系列-14>输入两个整数序列。其中一个序列表示栈的push顺序, 判断另一个序列有没有可能是对应的pop顺序。