|
|
вернуться в форумCorrect idea is HERE Use two arrays: Ans,Status : Array [1 .. 25000] Of Word; Ans is answers of children, Status is current status of every of them. First Status = DUP(0), and then Status[i] = 0 - if child i have unknown status 1 - if child's answer is "Me!!!" k - if we marked him(or her) on step k(k >= 2) In every iteration we searching for child with unknown status(p). If his(or her)answer is "Me" we making his(or her) status equal to 1, else we mark him(or her) with k and going to check child Ans[p]. If we meet status=k in our checking then cycle is found. Else we continue this process until we can find child with status = 0. Don't forget calculate children with status = 1. My solution on Pascal got AC with 0.62 sec., 127K. P.S. Sorry for bad English. I just use 0.203s Послано hello 15 май 2004 23:08 After system upgrade it works 0.234 sec. Re: Correct idea is HERE /*AC*/ double time = 0.14; long memory = 349; //КБ return; I am not use your idea!!! No optimization!!! Edited by author 25.07.2005 14:03 Edited by author 25.07.2005 14:04 Edited by author 25.07.2005 14:05 My more faste and memory LOW!! 885512 02:26:18 29 июл 2005 Tolstobrov_Anatoliy[Ivanovo SPU] 1211 Pascal Accepted 0.062 223 КБ Who can better???? Oh foget!! I USE const coll=25000; var m:array[0..coll]of word; z,b:array[0..coll]of boolean; t,i,k,j,n:word; kk,gg,bb:boolean; |
|
|