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

SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by tracy 12 May 2005 18:48
send to the following address:tracy_wz@126.com
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Gigzzz(gigz@inbox.ru) 14 May 2005 01:26
just use
vector<int> A[1001];

and you'll got AC:)
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Tabledott 14 Jun 2006 16:32
I was wrong


Edited by author 23.07.2006 13:55
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Todor Tsonkov 23 Jul 2006 13:54
You get memory limit in this way, not accepted :)
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Michael Medvedev 1 Apr 2007 20:11
I tried this, but MLE also

#include <cstdio>
#include <stack>
#include <map>
using namespace std;

map<int,stack<int> > m;
int i,n,a,b;
char command[10];

void main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%s",command);
    if (command[1] == 'U')
    {
      scanf("%d %d\n",&a,&b);
      m[a].push(b);
    }
    else
    {
      scanf("%d\n",&a);
      printf("%d\n",m[a].top());
      m[a].pop();
    }
  }
}

It's better than vector<int> A[1001];
But anyway, I need to hold all data that is pushed in stack!
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Tbilisi SU: Andrey Lutsenko 3 Apr 2007 20:08
long data[100001];
long top[1001];
unsigned char arr[12501*17];

I used this and some bitwise arithmetics to push 100000 integers into 17 bits each =)
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by partisan (Andrey Korotkov) 7 Nov 2007 15:47
I use bitwise atithmetic in Pascal, but got MLE :(
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Posted by Giorgi Saghinadze (Tbilisi SU) 8 Nov 2007 12:06
simple O(N^2) solution with some optimizations gets AC.