1410 - Consistent Verdicts(规律)

时间:2022-09-04 22:29:32
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&lpar;规律)

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

  2. LightOJ 1410 Consistent Verdicts&lpar;找规律&rpar;

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

  3. lightoj--1410--Consistent Verdicts&lpar;技巧&rpar;

    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&lpar;dfs优化&plus;规律枚举&rpar;

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

  7. 如何在ASP&period;NET Web站点中统一页面布局&lbrack;Creating a Consistent Layout in ASP&period;NET Web Pages&lpar;Razor&rpar; Sites&rsqb;

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

  8. hdu1452 Happy 2004&lpar;规律&plus;因子和&plus;积性函数&rpar;

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

  9. Codeforces Round &num;384 &lpar;Div&period; 2&rpar; B&period; Chloe and the sequence(规律题)

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

随机推荐

  1. Linux ftp访问控制配置&comma;包括访问ftp权限和访问ftp目录权限

    在Linux 上建立用户为website1 home目录是/data/home/website1 但是用ftp登录以后,路径可以随便切换,并且可以进入别的站点下 进行增.删.改 本篇的目的是:在lin ...

  2. DB Connection String

    SQL: Data Source=APGZDB04;Initial Catalog=ChinaEDI;Persist Security Info=True;User ID=edi_ac;Passwor ...

  3. jquery ui autoComplete自动完成

    官网:http://jqueryui.com/autocomplete 最简单的形式: var availableTags = [ "ActionScript", "Ap ...

  4. 程序里面的system&period;out&period;println()输出到其他位置,不输出到tomcat控制台。

    设置startup.bat: call "%EXECUTABLE%" run %CMD_LINE_ARGS% >> ..\logs\kongzitai.txt 将sys ...

  5. BZOJ 1266&colon; &lbrack;AHOI2006&rsqb;上学路线route

    题目描述 可可和卡卡家住合肥市的东郊,每天上学他们都要转车多次才能到达市区西端的学校.直到有一天他们两人参加了学校的信息学奥林匹克竞赛小组才发现每天上学的乘车路线不一定是最优的. 可可:"很 ...

  6. JavaScript new Boolean&lpar;false&rpar; 其实是true

    Boolean类型是JavaScript原始数据类型(primitive type)之一:常用来表示 真或假,是或否:这个类型只有两个值:保留字true和false 一般用于控制语句:如下 if(Bo ...

  7. jquery文本框内容实时监控

    $("#A").bind("input propertychange", function () { $("#B").val($(this) ...

  8. IDEA中创建maven项目后解决main文件夹下目录不全的问题

    IDEA创建maven-archetype-webapp项目的时候,创建完成后发现在main文件夹下没有java,resource等源文件夹. 解决方法: 1.选择File->Project S ...

  9. nginx——配置 Nginx 错误页面优雅显示

    ...... http { location / { root html/www; index index.html index.htm; error_page 400 401 402 403 404 ...

  10. java匹配竖线的错误警示

    String s1 = "|"; // 输出 | System.out.println(s1); String s2 = s1.replaceAll("|",& ...