SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
Послано
tracy 12 май 2005 18:48
send to the following address:tracy_wz@126.com
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
just use
vector<int> A[1001];
and you'll got AC:)
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
I was wrong
Edited by author 23.07.2006 13:55
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
You get memory limit in this way, not accepted :)
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
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!!
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!!
I use bitwise atithmetic in Pascal, but got MLE :(
Re: SOS! WHO CAN SEND ME THE C++ CODE OF THIS PROBLEM!!
simple O(N^2) solution with some optimizations gets AC.