|
|
вернуться в форумПоказать все сообщения Спрятать все сообщения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 |
|
|