Oh no ! Now I got WA test#10 ! Please help me !
Here my code :#include <stdio.h>
long C[10] = {1,2,4,8,16,32,64,128,256,512} ;
unsigned char B[125001] ;
long L[1000] , A[100000] ;
long stack , tt , bd , pt , i , n , gt , j ;
char s[4] ;
void main()
{
scanf("%ld\n",&n) ;
pt = 0 ;
for ( i=1 ; i <= n ; i++ )
{
scanf("%s",&s);
if ( s[0] == 'P' && s[1] == 'O' )
{
scanf("%ld",&A[i]) ;
A[i] = - A[i] ;
}
else
{
scanf("%d%ld",&stack,&A[i]) ;
pt = pt + 1 ;
bd = (pt-1) * 10 ;
for ( j = 0 ; j <= 9 ; j++ )
if ( stack & C[j] )
B[ (bd+j)/8 ] = B[ (bd+j)/8 ] | C[ (bd+j) & 7 ] ;
}
}
for ( i=n ; i > 0 ; i-- )
{
if ( A[i] >= 0 )
{
stack = 0 ;
bd = (pt-1) * 10 ;
for ( j = 0 ; j <= 9 ; j++)
if ( B[ (bd+j)/8 ] & C[ (bd+j) & 7 ] ) stack = stack | C[j] ;
pt = pt - 1 ;
if ( L[stack] > 0 )
{
gt = L[stack] ;
tt = A[gt] ;
A[gt] = - A[i] ;
L[stack] = tt ;
}
A[i] = 1 ;
}
else
{
stack = - A[i] ;
A[i] = L[stack] ;
L[stack] = i ;
}
}
for ( i=1 ; i <= n ; i++ ) if ( A[i] <= 0 ) printf("%ld \n",-A[i]) ;
}