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 1220. Stacks

Any tips (-) ??
Posted by uuuuuuu 1 May 2003 17:48
Tip Inside (+)
Posted by Evil Hacker 2 May 2003 05:18
I used next algo.
Let Value[i] be some value.
Let Prev[i] be previouse to i element. It is 3 byte value!!! This was
made using next feature: I store Ind1[i], Ind2[i], Ind3[i] of byte
then when i need real index i use Ind1[i]*256*256  +  Ind2[i]*256 +
Ind3[i].
Top[i] - index of top of stack.

for i <- 1 to N do
  fetch[read] op.
  if it is PUSH(st, x) then
      Value[i] = x
      Prev[i] = Top[st]
      Top[st] = i
  if it is POP(st) then
      WriteLn(Value[Top[St]]);
      Top[St] = Prev[Top[St]]
Thanks a lot !!!(-)
Posted by uuuuuuu 3 May 2003 18:45
Re: Tip Inside (+)
Posted by TheBeet 17 May 2004 13:43
>I used next algo.
>Let Value[i] be some value.
>Let Prev[i] be previouse to i element. It is 3 byte >value!!! This was
>made using next feature: I store Ind1[i], Ind2[i], Ind3[i] >of byte
>then when i need real index i use Ind1[i]*256*256 + Ind2[i]>*256 +
>Ind3[i].
>Top[i] - index of top of stack.

Can it be AC?

It use (4+3)*N btye.
If N=100000 It must be memory limit.

Edited by author 17.05.2004 13:44