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

Why WA #10?
Posted by ruX 18 Dec 2006 23:10
Does anybody can give me input data for this test?

My source:
....

#pragma pack (push)
#pragma pack (1)
struct tItem{ short st;  unsigned int val; };
#pragma pack pack(pop)

class tBigStack {
private:
   tItem el[100001];
   int stp;

public:
   tBigStack(void){ stp = 0; }
   ~tBigStack(void){ }

   short lastel(int st){
      for (int i = stp; i >= 0; i--)
         if (el[i].st == st) return i;
      return -1;
   }

   bool isempty(int st){ return lastel(st) < 0; }

   void push (int st, unsigned int v){
      el[stp].st = st;
      el[stp].val = v;
      stp++;
   }

   unsigned int pop(int st){
      int p = lastel(st);
      if (p < 0) return 0;
      el[p].st = -1;
      return el[p].val;
   }
};

....

I'm think is must work.