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 ;
}

1410 - Consistent Verdicts(规律)的更多相关文章

  1. LightOJ - 1410 - Consistent Verdicts(规律)

    链接: https://vjudge.net/problem/LightOJ-1410 题意: In a 2D plane N persons are standing and each of the ...

  2. LightOJ 1410 Consistent Verdicts(找规律)

    题目链接:https://vjudge.net/contest/28079#problem/Q 题目大意:题目描述很长很吓人,大概的意思就是有n个坐标代表n个人的位置,每个人听力都是一样的,每人发出一 ...

  3. lightoj--1410--Consistent Verdicts(技巧)

    Consistent Verdicts Time Limit: 5000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Su ...

  4. 初次使用SQL调优建议工具--SQL Tuning Advisor

    在10g中,Oracle推出了自己的SQL优化辅助工具: SQL优化器(SQL Tuning Advisor :STA),它是新的DBMS_SQLTUNE包. 使用STA一定要保证优化器是CBO模式下 ...

  5. 转 白话解析:一致性哈希算法 consistent hashing

    摘要: 本文首先以一个经典的分布式缓存的应用场景为铺垫,在了解了这个应用场景之后,生动而又不失风趣地介绍了一致性哈希算法,同时也明确给出了一致性哈希算法的优点.存在的问题及其解决办法. 声明与致谢: ...

  6. party lamps(dfs优化+规律枚举)

    Problem description: To brighten up the gala dinner of the IOI'98 we have a set of N coloured lamps ...

  7. 如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites]

    如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites] 一.布局页面介绍[Abo ...

  8. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  9. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

随机推荐

  1. 优化器的使用oracle ---explain plan

    如果要分析某条SQL的性能问题,通常我们要先看SQL的执行计划,看看SQL的每一步执行是否存在问题. 如果一条SQL平时执行的好好的,却有一天突然性能很差,如果排除了系统资源和阻塞的原因,那么基本可以 ...

  2. load和ready

    <一>ready和load ready先执行,load后执行 DOM文档加载的步骤: () 解析HTML结构. () 加载外部脚本和样式表文件. () 解析并执行脚本代码. () 构造HT ...

  3. jQuery.validate 中文 API

    名称 返回类型 描述 validate(options) Validator 验证所选的 FORM. valid() Boolean 检查是否验证通过. rules() Options 返回元素的验证 ...

  4. PGA与SGA

    当用户进程连接到数据库并创建一个对应的会话时,Oracle服务进程会为这个用户专门设置一个PGA区,用来存储这个用户会话的相关内容.当这个用户会话终止时,数据库系统会自动释放这个PAG区所占用的内存. ...

  5. IPv6地址的ping、telnet等操作

    最近在研究https协议是如何传输数据的,用wireshark抓包分析,发现客户机和google网站在传输数据时使用了IPv6地址,于是相对ipv6地址测试下基本的功能. ping功能,直接使用pin ...

  6. IOS 表视图(UITableVIew)的使用方法(3)名单的索引显示

    当数据量特别大时,简单地以role进行分段,对实际查找的效率提升并不大.就像上一节开头所说,开发者可以根据球员名字的首字母进行分段,且分成26段.由于段数较多,可以使用UITableView的索引机制 ...

  7. 射频识别技术漫谈(20)——RC系列射频接口芯片

    目前基于13.56MHz的射频识别技术主要有ISO14443A.ISO14443B.ISO15693和FELICA技术.针对13.56MHz的射频识别技术,NXP开发了一系列名字以RC(Radio C ...

  8. 工程中.pch文件的作用 及使用方法

    #ifdef __OBJC__ #define ABC 10#import "UIImage+Image.h"// 配置pch: buildSetting -> prefix ...

  9. [置顶] Android资源文件分析

    1)修改开机默认壁纸 Android开机默认资源文件为:frameworks/base/core/res/res/values/config.xml 我们找到wallpaper行: <strin ...

  10. POJ 2695 The Pilots Brothers' refrigerator(神奇的规律)

    转载请注明出处:http://blog.csdn.net/a1dark 分析:如果想要将一个“+”翻转成“-”,那么必然会把对应的行和列上的所有点翻转一次.由于一个点翻偶数次就相当于不翻转.所以我需要 ...