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

Can someone help. please... I think my algorithm is right but... may be it is not!!!
Posted by Vladimir Milenov Vasilev 17 Jan 2002 20:41
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.
A little change of your program
Posted by Andrey Popyk (popyk@ief.tup.km.ua) 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.
Thanks...I got accepted!!!!
Posted by Vladimir Milenov Vasilev 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...
Re: A little change of your program
Posted by Alex[LSD] 26 Sep 2002 12:26
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?..
Thank you very much! I got AC!!!!! ^_^
Posted by Марина 17 May 2004 22:20
Thanks. :)))