Light OJ-----1410---Consistent Verdicts

Consistent Verdicts

Time Limit: 5 second(s)Memory Limit: 32 MB

In a 2D plane N persons are standing and each of themhas a gun in his hand. The plane is so big that the persons can be consideredas points and their locations are given as Cartesian coordinates. Each of the Npersons fire the gun in his hand exactly once and no two of them fire at thesame or similar time (the sound of two gun shots are never heard at the sametime by anyone so no sound is missed due to concurrency). The hearing abilityof all these persons is exactly same. That means if one person can hear a soundat distance R1, so can every other person and if one personcannot hear a sound at distance R2 the other N-1persons 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 theyhave heard (not including their own shot) and they give their verdict. It isnot possible for you to determine whether their verdicts are true but it ispossible for you to judge if their verdicts are consistent. For example, lookat 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 5respectively. After all five of them have shot their guns, you ask them howmany shots each of them have heard. Now if there response is 1, 1, 1, 2 and 1respectively then you can represent it as (1, 1, 1, 2, 1). But this is aninconsistent verdict because if person 4 hears 2 shots then he must have heardthe shot fired by person 2, then obviously person 2 must have heard the shotfired by person 1, 3 and 4 (person 1 and 3 are nearer to person 2 than person4). 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 sois (2, 2, 2, 1, 1). In this scenario (5, 5, 5, 4, 4) is not a consistentverdict because a person can hear at most 4 shots.

Given the locations of N persons, your job is to findthe total number of different consistent verdicts for that scenario. Twoverdicts 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 twointegers xi yi (0 ≤ xi, yi≤ 30000) denoting a co-ordinate of a person. Assume that all theco-ordinates are distinct.

Output

For each case, print the case number and the total number ofdifferent 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个人的坐标,每个人的听力可自由设定而且相同,轮流开枪,问所有人听见的枪声数有几种组合

因为听力相同,很显然求出两两距离然后去重就可以了,最后如果听力比最小距离还小,会出现全听不见的情况,所以最后+1

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 5e5+10;
const int MOD = 1e9+7; 
struct node{
	int x, y;
}G[MAXN];
double dp[MAXN];
int main(){  
    int t, n, kcase = 1;
    scanf("%d", &t);
    while(t--){
    	scanf("%d", &n);
    	int ans = 0;
    	for(int i = 1; i <= n; i++) scanf("%d%d", &G[i].x, &G[i].y);
    	for(int i = 1; i < n; i++){
    		for(int j = i+1; j <= n; j++){
    			dp[ans++] = sqrt(1.0*(G[i].x-G[j].x)*(G[i].x-G[j].x)+1.0*(G[i].y-G[j].y)*(G[i].y-G[j].y));
			}
		}
		sort(dp, dp+ans);
		double flag = dp[0];
		int cnt = 1;
		for(int i = 1; i < ans; i++){
			if(dp[i] != flag){
				flag = dp[i];
				cnt++;
			}
		}
		printf("Case %d: %d\n", kcase++, 1+cnt);
	}
    return 0;  
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值