1410 - Consistent Verdicts
Time Limit: 5 second(s) Memory Limit: 32 MB

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 the N 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 distance R1, so can every other person and if one person cannot hear a sound at distance R2 the other N-1 persons cannot hear a sound at distance R2 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 next N 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

Output for Sample Input

2

3

1 1

2 2

4 4

2

1 1

5 5

Case 1: 4

Case 2: 2

题解:

题意就是n个人每个人听到枪响次数的方案,由于距离问题有的人可能听不到枪响;其实就是不同距离的个数

代码:

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
set<double>st;
const int MAXN=1e6;
double c[MAXN];
struct Node{
int x,y;
};
Node dt[];
double getd(Node a,Node b){
int x=a.x-b.x,y=a.y-b.y;
return sqrt(1.0*x*x+y*y);
}
int main(){
int T,N,flot=;
scanf("%d",&T);
while(T--){
scanf("%d",&N);
for(int i=;i<N;i++)
scanf("%d%d",&dt[i].x,&dt[i].y);
// st.clear();
int k=;
for(int i=;i<N;i++)
for(int j=i+;j<N;j++)
c[k++]=getd(dt[i],dt[j]);
//st.insert(getd(dt[i],dt[j]));
int ans=k;
sort(c,c+k);
for(int i=;i<k;i++)
if(c[i]==c[i-])ans--;
printf("Case %d: %d\n",++flot,ans+);
}
return ;
}

最新文章

  1. zabbix自定义key
  2. JavaScript利用装饰模拟实现私有状态
  3. 安装rabbitMQ delayed-messaged
  4. C#socket通信-----多线程
  5. C# 匿名方法
  6. 最简单的PHP socket echo server。
  7. 从 Java 代码逆向工程生成 UML 类图和序列图
  8. bzoj2754
  9. CodeIgniter框架——介绍
  10. Linux的VI/VIM
  11. MyEclipse的真正价值——时间等于金钱
  12. 大数据处理的三种框架:Storm,Spark和Samza
  13. java http缓存
  14. mysql的基本操作笔记
  15. Learning-Python【32】:进程理论基础
  16. 2017-11-04 Sa Oct 消参
  17. 多目标遗传算法 ------ NSGA-II (部分源码解析)辅助变量 双链表操作 list.c
  18. The Little Prince-11/26
  19. ubuntu下修改文件权限
  20. SVG Animation

热门文章

  1. Cookie获取、设置值
  2. C++ 字符串指针与字符串数组
  3. BZOJ 1050: [HAOI2006]旅行comf( 并查集 )
  4. Bootstrap第一天
  5. 大概看了一天python request源码。写下python requests库发送 get,post请求大概过程。
  6. PC游戏编程(入门篇)(前言写的很不错)
  7. 在GridView中实现全选反选的例子
  8. 开源流媒体处理库live555服务器端、客户端源代码分析总结
  9. java学习之坦克大战游戏
  10. 使用jetty和mongodb实现简易网盘接口