ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1087. The Time to Take Stones

Here is my program. I used dynamic but got wrong answer...I don't
know why???? If someone can give me some test...

program The_time;
var used : array[1..10000] of boolean;
    a:array[0..10000] of byte;
    st : array[1..50] of integer;
    n,k,i,j : integer;
    bool:boolean;
Begin
readln(n,k);
for i:=1 to k do read(st[i]);
a[0]:=1;
for i:=1 to n do a[i]:=0;
for i:=1 to n do
 Begin
  bool:=false;
  for j:=1 to k do
  if i>=st[j]
  then if a[i-st[j]]=2
       then
        Begin
         a[i]:=1;
         break;
        End
       else if a[i-st[j]]=1
            then if bool=false
                 then bool:=true;
  if(bool)and(a[i]=0) then a[i]:=2;
 End;
writeln(a[n]);
End.
Andrey Popyk (popyk@ukr.net) A little change of your program [3] // Problem 1087. The Time to Take Stones 18 Jan 2002 17:43
program The_time;
var used : array[1..10000] of boolean;
    a:array[0..10000] of byte;
    st : array[1..50] of integer;
    n,k,i,j : integer;
    bool:boolean;
Begin
readln(n,k);
for i:=1 to k do read(st[i]);
a[0]:=1;
for i:=1 to n do a[i]:=0;
for i:=1 to n do
 Begin
  bool:=false;
  for j:=1 to k do
  if i>=st[j]
  then if a[i-st[j]]=2
       then
        Begin
         a[i]:=1;
         break;
        End;
  if a[i]=0 then a[i]:=2; {See here!}
 End;
writeln(a[n]);
End.
Vladimir Milenov Vasilev Thanks...I got accepted!!!! // Problem 1087. The Time to Take Stones 18 Jan 2002 19:22
> Thank you very much, i got accepted now!!!Although I can't find
what was wrong with my program, but I'll will try to find. If I can
help with something, just ask me...
Ok I got AC too. great! thanks!

Not I d really love to know what difference that makes, for example
how the hack could the first player win in that test case?..
Thanks. :)))