Common Board| Show all threads Hide all threads Show all messages Hide all messages | | My program is 0.656 s,how can I get faster? | acmore | 1004. Sightseeing Trip | 30 Jun 2010 00:12 | 2 | My solution is O(N^4). Edited by author 06.08.2009 08:42 Edited by author 06.08.2009 08:42 You should use Dijkstra algorithm for every vertex. In algorithm you should find two different best ways from current vertex V to any other A. The summary length of this two ways is the length of the shortest cycle with vertexes A and V. | | No subject | Vedernikoff Sergey (HSE: АОП) | 1752. Tree 2 | 28 Jun 2010 22:15 | 3 | No subject Vedernikoff Sergey (HSE: АОП) 28 Jun 2010 01:14 No subject Edited by author 28.06.2010 22:13 I think your algo will fail on this test: 11 2 1 2 2 3 2 6 3 4 6 5 1 7 7 8 7 9 8 10 9 11 4 1 5 1 Answer: 3 6 Thank you, man! Your invaluable test helped me to understand where I'm wrong. The algo itself is correct, but my realization has silly flaw... | | please give me right answer for this testcases... | napst101r | 1747. Kingdom Inspection | 28 Jun 2010 04:41 | 2 | 1000 1000000007 100000 1000000007 thanks If this will help you somehow... 1000 1000000007 -> 161507394 100000 1000000007 -> 573507585 | | long long wa@test2,,,and __int64 got AC,, | acmore | 1010. Discrete Function | 27 Jun 2010 16:25 | 2 | I also have this weird problem. Long long variables got WA@2, and if changed to long double everything is AC... | | For those who got WA#2 | MitRo | 1047. Simple Calculations | 27 Jun 2010 08:03 | 1 | Hi all! I used Binary Search to solve this problem (because I'm not good at Math) and got AC after WA#2 3 times. For getting AC, I changed my print line from: cout << result << endl; // or print("%f\n", result); To: print("%.2f\n", result); It means you must format your result with 2 precisions after the decimal point, or your result will be something like: 14.99038461538461538461538461538462 (many number after the decimal point). I hope this would help. Please reply and notice me if there is something wrong. MitRo. | | help me on test 59 | mmmmmm | 1216. Two Pawns and One King | 27 Jun 2010 01:55 | 2 | I submited many time but all -> wr on test 59. could anyone help me ?? this test helped me: 8 b2 c4 h1 | | who is answer it now,i had passed today, simple DP! | gjlsx | 1031. Railway Tickets | 26 Jun 2010 23:53 | 3 | who is answer it now,i had passed today, simple DP What a poor English :) Did anybody get what he was going to say? not really.. haha =) probably he's just bragging that he got it! =) | | I can't find good algo. Who can help me? | Ludi Elektropitanioya | 1497. Cutting a Square | 26 Jun 2010 16:10 | 1 | | | I use dp and got ac!!!! | xiaoc | 1223. Chernobyl’ Eagle on a Roof | 26 Jun 2010 14:17 | 1 | | | No subject | Man'ka_NN | 1654. Cipher Message | 26 Jun 2010 05:05 | 1 | Edited by author 29.06.2010 01:10 Edited by author 29.06.2010 01:10 | | Hints | BFL | 1103. Pencils and Circles | 26 Jun 2010 00:04 | 2 | Hints BFL 13 Nov 2005 11:05 1. there are always solutions. 2. convex polygon. but don't need to find. Edited by author 10.12.2005 05:18 Hey can you give me an idea of using convex polygons for this problem?? I solved it in O(n^2), tho it can be done in O(nlogn), but none of my solutions uses convex hulls... | | WA #5 | Rybinsk SAAT (Samsonov) | 1497. Cutting a Square | 25 Jun 2010 19:30 | 4 | WA #5 Rybinsk SAAT (Samsonov) 15 Oct 2006 18:50 now AC. Edited by author 15.10.2006 23:59 5 00000 01110 01110 01110 00000 No Edited by author 05.05.2009 14:15 | | O(n) algo with java BigInteger is getting TLE 15 HELP PLEASE | muhammad | 1513. Lemon Tale | 25 Jun 2010 16:36 | 2 | I used O(n) with sum and subtract. But it's too slow to AC Please someone help me. pp: please sorry got AC. i calculated power every time which made it slow later i just multiplied by 2 each time which gave AC | | How to solve this one? | Douglas Cardoso | 1359. Construction | 25 Jun 2010 11:39 | 1 | I really couldn't figure out how to solve it. The way I tried even gives the wrong output for the sample! I modelled like this: Each integer coordinates point represents a node of a graph. There is a edge form point (a, b) to (c, d) iff a >= c and b > d. The edge's weight is equal to the time to go from one point to another one adjacent to the first, which is calculated like this: if theta is the angle between the segment (a, b)-(c, d) and the x-axis, then due to the gravity there is a 10*cos(theta) acceleration in the x-axis direction. So the time needed to go from (a, b) to (c, d) is sqrt(2*(c-a)/(10*cos(theta))). Finally, what I do is to run a shortest-path algorithm in this graph. But for the sample my program answers 0.752121. Does any one knows if ignored any detail? Or maybe if my entire model is wrong? Thanks! | | why answer for '2 100' is 14 ??? | MSU Teminator | 1223. Chernobyl’ Eagle on a Roof | 25 Jun 2010 09:05 | 3 | my answer for '2 100' is 51 The first drop is from 14-th floor. If the egg is broken => F(1,13)+1=13+1=14 Than from 27-th floor If the egg is broken => F(1,27-14-1)+2=12+2=14 Than from 39-th floor If the egg is broken => F(1,39-27-1)+3=11+3=14 Than from 50-th floor, 60-th, 69-th, 77-th, 84-th, ... | | Bolshoyo Spasiba vam_____-- Vladimir Yakovlev (USU), (Thank you)) | Qafqaz_Ferhad Cebiyev | 1133. Fibonacci Sequence | 24 Jun 2010 23:13 | 1 | | | How to prove the result??? | Vedernikoff Sergey (HSE: EconomicsForever!) | 1622. Endspiel | 22 Jun 2010 17:18 | 10 | How to prove that only for you-know-what cells there exists an answer? I brute-forced it (~30 mins as I used 1Gb RAM computer, so I had to calculate 1, 2, 3, ... n steps separately and store results on HDD for further path-tracing between reachable states). Edited by author 09.09.2008 02:52 * Брэнд 24 Oct 2008 23:57 It's very easy task if you know the game "Soliter")) Re: * LDT 30 Oct 2008 13:59 It's very easy task if you know the game "Soliter")) can you tell more about that? Re: * Maxim Dvoynishnikov (Dnipropetrovsk SU) 30 Oct 2008 19:42 Re: * Vedernikoff Sergey (HSE: EconomicsForever!) 31 Oct 2008 03:25 And how does this solitaire help to solve the problem? Re: * LDT 3 Nov 2008 01:43 yes, i don't see any relation with the solitarie. Although i've played many times (in the past) Re: * 2rf [Perm School #9] 17 Jun 2010 16:35 Re: * Sevenk 22 Jun 2010 17:18 Oh, you showed us the solution. Well, try coloring the cells of the field in numbers 3,5,6 so that in each row they repeat: 3,5,6,3,5,6,... and the top-left to bottom-right diagonals are always "one-color". Then play with possible moves and XORs of the values. Then change the direction of one-color diagonals and repeat all the reasoning. This will certainly help you. | | who wants AC in Java use BigInteger | qafqaz Xeyyam | 1224. Spiral | 22 Jun 2010 16:36 | 1 | When I use doubele i got wrong in 12. But after I use BigInteger and got AC. | | Why WA #3? It seems so simple. | Maigo Akisame (maigoakisame@yahoo.com.cn) | 1317. Hail | 22 Jun 2010 03:53 | 3 | program ural1317; const maxn=10; zero=1e-6; var x,y:array[1..maxn+1]of real; n,k,i,ans:longint; h,d,a,b,u,v:real; function cross(xa,ya,xb,yb,xc,yc:real):real; var x1,y1,x2,y2:real; begin x1:=xb-xa;y1:=yb-ya; x2:=xc-xa;y2:=yc-ya; cross:=x1*y2-x2*y1; end; function dist(xa,ya,xb,yb:real):real; begin dist:=sqrt(sqr(xa-xb)+sqr(ya-yb)); end; procedure shoot; var i:byte; l,r:real; begin for i:=1 to n do if cross(a,b,u,v,x[i],y[i])*cross(a,b,u,v,x[i+1],y[i+1])<=0 then begin l:=dist(a,b,u,v); if l<zero then begin inc(ans);exit;end; if d<l then exit; r:=abs(cross(a,b,x[i],y[i],x[i+1],y[i+1]))/dist(x[i],y[i],x[i+1],y[i+1]); if sqrt(d*d-l*l)/l*r>h then inc(ans); exit; end; end; begin read(n,h); for i:=1 to n do read(x[i],y[i]); x[n+1]:=x[1];y[n+1]:=y[1]; read(d,a,b,k); for i:=1 to k do begin readln(u,v); shoot; end; writeln(ans); end. program ural1317; const maxn=10; zero=1e-6; var x,y:array[1..maxn+1]of real; n,k,i,ans:longint; h,d,a,b,u,v:real; function cross(xa,ya,xb,yb,xc,yc:real):real; var x1,y1,x2,y2:real; begin x1:=xb-xa;y1:=yb-ya; x2:=xc-xa;y2:=yc-ya; cross:=x1*y2-x2*y1; end; function dist(xa,ya,xb,yb:real):real; begin dist:=sqrt(sqr(xa-xb)+sqr(ya-yb)); end; procedure shoot; var i:byte; l,r:real; begin for i:=1 to n do if cross(a,b,u,v,x[i],y[i])*cross(a,b,u,v,x[i+1],y[i+1])<=0 then begin l:=dist(a,b,u,v); if l<zero then begin inc(ans);exit;end; if d<l then exit; r:=abs(cross(a,b,x[i],y[i],x[i+1],y[i+1]))/dist(x[i],y[i],x[i+1],y[i+1]); if sqrt(d*d-l*l)/l*r>h then inc(ans); exit; end; end; begin read(n,h); for i:=1 to n do read(x[i],y[i]); x[n+1]:=x[1];y[n+1]:=y[1]; read(d,a,b,k); for i:=1 to k do begin readln(u,v); shoot; end; writeln(ans); end. Your algo to find intersection point is wrong. Use algo to find intersection point of 2 lines with modifications. | | Can't Understand the Problem | Varun Sharma | 1317. Hail | 22 Jun 2010 03:50 | 2 | Hi, How come the answer for the test case is three when all the points 0,0 1,1 2,2 3,3 and 4,4 are within 50 meters of the laser. The answer should be 5 ? isn't it ? Also, what are the roles of fence and convex polygon here ? can't seem to get that as well ! Thanks Laser can't shoot through polygon and height of wall is important. |
|
|