|  | 
|  | 
| back to board | OutputLimit #3 Please HELP!!!! Posted by B!GO  21 Feb 2007 00:33I got Output Limit on Test#3This Is My CODE:
 
 #include<iostream>
 using namespace std;
 
 
 char stack[50000][14];
 int pos=0;
 bool ii=true;
 
 void push(char a[4],char b[9])
 {
 int i;
 int l=strlen(a);
 for(i=0;i<l;i++)
 stack[pos][i]=a[i];
 stack[pos][i]='#';
 i++;
 int ll=l+strlen(b)+1;
 for(;i<ll;i++)
 stack[pos][i]=b[i-l-1];
 pos++;
 }
 void pop(char a[4])
 {
 
 
 int i;
 int j;
 for(i=pos-1;i>=0;i--)
 {
 ii=true;
 j=0;
 if(stack[i][0]!='~')
 {
 while(stack[i][j]!='#')
 {
 if(a[j]!=stack[i][j])
 {
 ii=false;
 break;
 }
 j++;
 }
 j++;
 
 
 if(ii)
 {
 int sl=strlen(stack[i]);
 for(;j<sl;j++)
 {
 cout<<stack[i][j];
 }
 cout<<endl;
 
 
 
 
 stack[i][0]='~';
 return;
 }
 }
 
 
 }
 
 }
 
 int main()
 {
 char a[4],b[9];
 char tmp[4];
 char cc;
 int n;
 cin>>n;
 for(;n>=1;n--)
 {
 tmp[0]='~';tmp[1]='~';tmp[2]='~';tmp[3]='~';
 cin>>tmp;
 if(tmp[1]=='U')
 {
 cin>>a>>b;
 push(a,b);
 }
 else
 {
 cin>>a;
 pop(a);
 }
 }
 
 
 
 
 return 0;
 }
 
 Edited by author 21.02.2007 00:33
 | 
 | 
|