|
|
Hi, all. My program is generating all possible lines [ so they are only less or equal to C(n,2) lines were kept ]. I keep 'M' and 'C' of every line, sort them and then count the most appeared lines. When I count the most appeared lines, I multiplied it by 2, take sqrt and ceil it up. Like this : ans = (int) ceil(sqrt(2.0* max)); Above is from C(n,2) = maxline I use the formular c = (x1 y2 - x2 y1) / x1-x2 After I received WA#4 the first time, I changed all my code to keep M and C in fraction [ didn't divide it but keep 2 values ] to avoid error from floating point. I still get WA on test #4. Could anyone give me test case #4 to me, or some of test cases which might help me please? Thank you all in advance and sorry for my poor English ;-) don't try to use the concept of slope.Try to use the idea that if 3 points are collinear the area of triangle formed by those points is 0.Then u can avoid fractions.Note even that double values cannot be compared exactly which lead to WA.So try use the above idea Well actually, if you know the O(n^2*logn) algorithm is simple -- using hash function which tells you for A,B and C of the line equation how many rabbits are before and just add. Is it possible that several rabbits sitting on top of each other at exactly the same location? No two rabbits sit at one point It seems that everything in my program is OK, but I still got the "Wrong Answer". I wonder if someone can tell me if there is some tricks in the program that I had neglected. I think there's no trick on this problem. The solution as you may know is taking 2 points, do the lineal equation and try for all the points if match in the line. Well, for this problem i saw the fact that you can use integers without trying with floating point values (how in city blocks) maybe a fact of rounding cause that you are not taking some points. Hope this help you: dy = y[j]-y[i]; dx = x[j]-x[i]; mx = 0; for (k=0; k<N; k++) if (y[k]*dx==dy*(x[k]-x[i])+dx*y[i]) ++mx; Value N=200 allow use O(N^3) algo. Therefore better more simple and verified algorithm. But there is 1422("svetlatcki") with N=2000 and n=3 which the same but need O(n^2lg(n)). After 1052 try 1422 and question will be understood at hole. Edited by author 09.03.2007 20:39 Edited by author 09.03.2007 20:42 1422 can be done with O(n^2) I used 'Extended' in Pascal(equals to 'long doulbe' in C++); Can it be OK? I used 'Extended' in Pascal(equals to 'long double' in C++); Can it be OK? Can rabbits be sutuated on diagonal? //Sorry for me English This is my program in Pascal: [code deleted] Edited by moderator 06.07.2006 15:01 here it's test 3 (I don't know what is that last 0, but so it is. It should not matter): 16 15 15 16 17 17 19 18 21 19 23 75 19 16 62 13 69 10 76 7 83 4 90 1 97 -2 104 -5 111 -8 118 -11 125 The answer is: 10 (last 10 points of the input) What points are coliniar? The points called coliniar if they lie on one line. For example (1,1) (2,2) (3,3) are coliniar. Edited by author 11.04.2005 02:22 try this: if you have: ------------ r:= y - k*x -n; if (result = 0) then on_line:= true else on_line := false; change it with: ------------ r := abs(y - k*x -n); if (result < 0.0000000001) then on_line:= true else on_line := false; I sent this task two times, but i was wondered. First time i got CE(LINK : fatal error LNK1104: cannot open file 'TEMPFILE') But when I sent it again I got AC. I got WA. PLZ give me some test. Thist of all I sorry for my bad English. Please, help me to solve this problem! I don't understand why I get Crash(Access_Violation), then I use Extended type. And then I use Real Type, my program gets WA. The time of my program's work T~O(N^2), but it works very slow more than 1.7 second on WA test. Please, help me to know good alghorithm. Thanks. Does the good hunter has to stand at the (0;0) point or wherever he's at the point he wants by the helicopter? The good hunter could stay at any point. Just find the biggest number of points, lying on one and same line - it doesn't need to be the line with equation y=x. I generate all lines posible, and then count the rabbits on it. I get WA, so what should I output for n=1 or something else?????? Well, the problem text says :
An input contains an integer N (2<=N<=200) So your question has no sense. N is NEVER EQUAL to 1. |
|
|