|
|
Common Boardprogram ti1029; var f:array[0..501,0..501]of integer; w,dp:array[0..501,0..501]of extended; i,j,k,n,m:integer; procedure print(x,y:integer); begin if x<>1 then begin if f[x,y]=y then print(x-1,y) else print(x,f[x,y]); end; writeln(y); end; begin readln(m,n); for i:=1 to m do for j:=1 to n do read(w[i,j]); fillchar(dp,sizeof(dp),0); fillchar(f,sizeof(f),0); for i:=1 to n do dp[1][i]:=w[1][i]; for i:=2 to m do begin for j:=1 to n do begin dp[i][j]:=dp[i-1][j]+w[i][j]; f[i][j]:=j; end; for j:=2 to n do if dp[i][j-1]+w[i][j]<dp[i][j] then begin dp[i][j]:=dp[i][j-1]+w[i][j]; f[i][j]:=j-1; end; for j:=n-1 downto 1 do if dp[i][j+1]+w[i][j]<dp[i][j] then begin dp[i][j]:=dp[i][j+1]+w[i][j]; f[i][j]:=j+1; end; end; j:=1; for i:=1 to n do if dp[m][i]<dp[m][j] then j:=i; print(m,j); end. try 5 6 525 0 171 0 872 673 0 843 0 0 0 0 0 277 0 202 0 0 0 0 733 957 65 96 637 566 0 0 0 441 answer: 4 4 5 5 5 5 some tests input 3 4 0 0 0 0 0 0 0 0 0 0 0 0 output 1 1 1(or some like that) input 3 4 1 0 0 0 1 0 0 0 0 1 1 2 output 2 2 1 1(or some like that) Edited by author 20.03.2009 11:32 Is 4 4 5 5 5 5 4 3 correct? The fee is a "positive" integer not exceeding 10^9. while(s+m/(2*t-1)<n){s+=m/(2*t-1);oil=t*m;t++;} ans=(n-s)*(2*t-1)+oil; printf("%.0lf",ans+0.5 - 1e-8); I got WA #35, and doubt if there are something wrong with accuracy in my program. Anybody have ideas? Well, accepted got now. For those who use the method of calculating the intersection of three circles, pay attention that there might be a circle inside another or internal tangent to another. who can tell me what #12 is? I don't know where my program is wrong.Thank you in advance. Edited by author 22.10.2012 13:22 is that task in dynamic programming style? Where you see in this task any optimal substructure (typical fo dp)? but when I use stack I have Time limit exceeded at 42 test Does correct test? Please give me test. Is fourth test correct? the problem seems to be very easy but idk, i have WA#4 too Same for me, fails at 4. Please double check. There are many fails on test 4. But it is absolutely correct, both test and answer were checked by hands multiple times. Look for error in your code. Does cylinder contains bottom and top? > Does cylinder contains bottom and top? Take a look at the sample inputs again. I've checked my formula with both kinds of formulas given in this article: http://www.jstor.org/discover/10.2307/2691523?uid=3739232&uid=2129&uid=2&uid=70&uid=4&sid=21101178420913 (if someone is interested in full version of article - mailto Oracle@acm.lviv.ua) I use BigInteger in Java - should be no precision issues. Results are the same for all rectangles with 1 <= sides <= 100 and for about a billion random test cases with 1 <= side <= 1000000. And still WA#4((( Is it definitely correct? Now I wonder if the problem is exactly in checking if one rectangle fits into others? Or I've missed something? Sorry for complaint. Seems that tests are correct - I've misunderstood the statement. Edited by author 21.10.2012 22:36 Edited by author 21.10.2012 22:39 This is my code... CONST MaxN = 10000000; VAR K, P : Longint; A : Array [1 .. MaxN] of Longint; PROCEDURE Solve; Var i : Longint; Begin A[1] := 0; A[2] := 1; for i := 3 to K do if i mod 2 = 0 then A[i] := (A[i - 1] + A[i div 2]) mod P else A[i] := A[i - 1] mod P; End; PROCEDURE Run; Begin ReadLn(K, P); Solve; WriteLn(A[K]); End; BEGIN Run; END. Were my mistake is? Sorry for my bad english... A[1] := 0; A[2] := 1; // this line is wrong, must be A[2] := 1 mod P test 1 1 answer is 0
thX AC What a stupid mistake I also made. Edited by author 21.10.2012 19:56 It doesn't look like it can be cleared out from a problem description. If so, does the speed of a cart remains equal 'v' after tunnel exiting, or the same, as at the end of a side tunnel? NO "Meanwhile, the wall of fire continued to approach the cart. Time was running out, and a plan had to be developed fast. WIZARDS CAN TURN TO A SIDE TUNNEL ONLY ONCE BECAUSE THE CART IS VERY OLD AND NOT SUITED WELL FOR MAKING TURNS. But which tunnel to use?" Edited by author 21.10.2012 12:13 Edited by author 21.10.2012 03:11 Edited by author 21.10.2012 03:11 I corrected my mistake!!! sorry for all ;) got AC! I had Crash 1!!! and solve in Java and found my mistake!!! Have you used any formula? or some sort of binary search? Edited by author 21.10.2012 01:21 1. What did the question marks ("?") mean in the contest standings page? And they disappeared when the contest finished. 2. In the judge status page, do the memory and time fields show the longest and biggest values in all finished tests or the values of the last test? Thanks Ade 1. "?" means that there were no accepted submissions for this problem in first 4 hours and there were some submissions in the last hour. So results are effectively frozen at 4:00 mark. 2. Longest and biggest. Thank you for your clear answers. One further question: What's the purpose of the freezing? Thanks Ade It was made for "keeping the intrigue". You may argue whether it should or shouldn't be done in internet contests, but in real contests with prizes it definitely makes sense. Thank you very much. What I do is just following the others' steps. I always try to solve the next easiest (solved most times) problem. So I guess it only matters much for the top guys. Ade Subject. Yes please! Hopefully very soon! is this because I am using java ?? Java is slower compared to c or c++. This program is normal stack operation isn't it? or some other algo is to be followed?? can any one please describe the input-output given? Может ли между двумя соседними по стороне комнатами не быть пустоты (пробел)? то есть верно ли, что каждая комната всегда окружена какими-то стенами и углами? |
|
|