湖大训练赛8 Bad Signal

来源:互联网 发布:大数据的定义及特点 编辑:程序博客网 时间:2024/05/01 20:00

Bad SignalTime Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KBTotal submit users: 19, Accepted users: 18Problem 12885 : No special judgementProblem description

There is an important UN meeting in town. Any self-respecting espionage agency will try to eavesdrop on the delegations to gain some advantage in the negotiations. They do this by planting hidden microphones in and around the meeting places. Those microphones continuously capture sound waves and transmit them via radio.
In fact, fierce competition between espionage agencies has left the whole city scattered with hidden microphones, so much so that the radio waves interfere with each other and it is often not even possible to make out any signal in the mess of radio waves ? depending on your position and proximity to the different transmitters obviously. Specifically, it is possible to make out a signal i if and only if:


Input

On the first line one positive number: the number of test cases, at most 100. After that per test case:
 one line with an integer n (0  n  100 000): the number of planted microphones.
 one line with the integer B (0  B  1 000 000): the level of background noise.
 one line with two space-separated integers x and y: the x and y coordinates of the location Plisten where you receive the signals.  n lines with three space-separated integers xi, yi and si (0 < si  1 000 000): the x and y coordinates of the location Pi of microphone i and its signal strength, respectively.
All coordinates are in the range [0; 10 000]. The locations Pi all differ from Plisten. The test data is constructed so that small floating point rounding errors will not influence the outcome of any solution.


Output

Per test case:
 one line with an integer: the (one-based) index of a microphone, the signal of which can be made out, or the string “NOISE” if there is no such microphone.


Sample Input
3410100 10090 90 20000110 90 5090 110 1000110 110 504100100 10090 90 20000110 90 5090 110 1000110 110 50200 100 0 10000 8 1
Sample Output
1NOISE1

很久没做HNU的训练赛了,太懒了吧,时间太蛋疼了,中午想午休的好么。但是看到水题能够得到Aceept还是很亢奋的。就不会想睡觉了。总觉得就是题目比较蛋疼难懂。

题意:有一个圆桌会议(好吧,圆桌我自己编的)开在坐标为xx,yy的地方,有个强度为B的值,知道就好,然后有N个麦克风,应该算窃听器吧。每个麦克风坐标是xi,yi,有一个si的值,这个知道就好了。问存不存在一个麦克风ti>6*(B+其他麦克风ti的和)有,则输出这个麦克风是第几个,没有则输出noise。具体ti的值怎么求已经给出公式了。这样问题就简单了,求出最大的麦克风ti值就可以比较了。具体见代码。

#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <iostream>#include <cmath>#include <queue>#include <map>#include <stack>#include <list>#include <vector>using namespace std;#define LL __int64#define ling 0.0000001struct node{double s;int p;}f[100010];int cmp(node a,node b){return a.s>b.s;}double dis(LL x1,LL y1,LL x2,LL y2){return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);}LL b,xx,yy,x,y,s;int main(){double ans;int T,n,i;scanf("%d",&T);while (T--){scanf("%d",&n);scanf("%I64d",&b);scanf("%I64d%I64d",&xx,&yy);ans=0;for (i=0;i<n;i++){scanf("%I64d%I64d%I64d",&x,&y,&s);f[i].s=s/dis(xx,yy,x,y);f[i].p=i+1;ans+=f[i].s;}sort(f,f+n,cmp);double max=6*(b+ans-f[0].s);if ((f[0].s-max>ling))printf("%d\n",f[0].p);else puts("NOISE");}return 0;}


0 0