long _4 , _5 ; ; # include <math.h> # include <conio.h> /* */ volatile long far * _3 = # define Z( D, O,N ) j =d [ O ] . D;d[ O ] . \ D=d [N ]. D;d[N ]. D = /* (c) DON YANG, 1999 */ +j ; ( long far* ) 1132L ; int w, m [ 3 ][ 2048 ] , n[ 25 ], t [ 2][9]= { { 30208, - 2560 , 30720 , - 2304 , 9984 , - 20736 , -21504 ,768 , 256 } , { 30720 , - 2304 , 29440 , - 1280 ,5888 , -24832 , -25344 , 768 , 512} } , _1[]= { 18 , 0 , 11, 22 ,3, 14, 25 , 6 , 17 , 28, 9, 20, 1 , 12 ,23,4 , 15,26 ,7 }, _2[ ]={ - 1 , 1, 0 , 1, 2 ,3 , 4, 5, 7, 7 , 9, 9} ,_0 [ 5 ][10] , e, f, r[5 ]= { 0 ,8, 7, 11 , 15 } ,g , h ,l [ 3] = { 68 , 79,78 }, s[ 6 ] [ 2 ] = { { 4063 , 0 } , { 30940 ,0} ,{ 30943 , 0 } , { 4060 , 0 },{ 2012 , 2271 } , { 2268 , 2015 } } , i , j , k ,x ,y, z ,c , a[4] ,b[4 ], far * o= ( int far * )( 23L << 27 ) ; struct _d { int p, x,y, i ,j , u , v , q ;}d[ 2001 ] ; double u , v,p,q, PI = 22 / 7. ; int X ( void) { _5=_5 * 0x343fdL + 0x269ec3L ; ; return (int )( _5 >> 16 )&32767 ;}void B(void ) { while ( *_3 == _4 );_4 = *_3 ; for ( i =0 ;i < 2000 ; )o [i++ ] =m[0 ] [i ] ; } void A( void) { if(c ++ & 1 ) { x = 96+X( )%48 ;y =84 - X ( ) % 48 ; }else{x= 84- X( )%48; y = 96+ X( )%48 ;} for ( i = 0; i< 2000 ;) m[ 0][i++]=-1 ;B () ;k =X ()&1 ;for ( z = k ? 0 : 7 ;z<8&& z>=0 ; z+=k ?1: -1) {for ( i= 0 ;i< 2000 ;) m [0][ i++]=0;for(i=(z< 4?0:z * 20 - 80);i <(z< 4?z*20+ 20 : 80 ); i ++ ){j =(i*(y- x ))/80+x ; m [ 0 ][n[j/6 ] +i ]= s[ j%6][0]; m[0 ] [n[j/ 6+1]+i] =s [ j %6 ][1];}B();}a[i=c- 1]=X( )%16+8;b[ i]=X()%16 +8;if(!(c &1))a [ i ]= - a [i ]; x /= 6;y/= 6 ;for (i =0;i< 80;i++){for( j=( i*( y -x))/80 +x;j >= 0;)m[1 ] [n [ j -- ] +i]= c ; } } void C(void){if (!getch ())getch (); }void D(void ){ for(i =0;i< 2000 ;)m[ 2][i ++ ]=o[ i ] ; for (i =e= 0;i< 2000;i++){if ((o[i]&255 )!=32|| ( o[i]&0xf000 )) {d[e ] .x= i% 80;d [ e ] .y= i /80 ; d [ e ]. q= o [i ];d[e++].u=X()% 64 +1;} }for(f=e; f&& !kbhit ();){for (i =0; i< 2000 ;)m [0] [ i ++ ] = 0 ; for ( i = e -1; i>=0;i --){if(d[i].u){m[0 ] [n[ d[i].y]+d[ i ].x]=d [i].q; if ( !( -- d[ i] . u) ){ d[i ] . i = X ( )% 4+6;d[i].j=X()%4;}}else{ if( d[ i] .y>=0&& d [i]. y < 25 &&d [i] . x >= 0 && d [i]. x <80 ){ m[0][n[d[i].y] +d[i].x] = d[ i]. q;} else {if( d[i].i ) { f--; d[i ].i=d [ i] . j = 0 ; } } d [ i ].x-=d[ i].i ;d[i].y +=d [ i] . j; }}B ( ) ;} if(kbhit ( ) ) C( ) ; } void G ( int x , int y , int t,int c ){ if (y>=0&& y< 25&& x>= 0&& x<80){ if( m [1] [n[y ] + x]) return ;m [ 1 ] [ n [y ]+ x ]= 1;d[ e ].x=x; d[ e] .y= y;d [ e ]. p=t;d[e ++] .q=c ;}} void F ( int x , int y , int i, int j , int t, int c ){u=(i -x) / 64.0 ; v = ( j -y )/ 64.0 ; for ( k = 0 ; k<= 64 ; k ++ )G( (int )(k * u ) +x,(int)(k* v )+y,t ,c );}void H( void ){ i= x = X () % 18 + 30 ; y =X()%4+11; c =x+8; for (j=y;j<25;j++){F( c- ( c -i) / 3,j ,c,j ,3 ,t[ w ] [0 ]) ; F ( i, j,c, j,3, t[w][1]); if((z=X())&3){if(z&4){i--; if(z&8)c --; } else { c ++; if ( z & 8) i ++ ;}if( c-i<4) z=(z&1)? i--:c++;if(c-i> 15 )z =( z & 1 )?i++ : c-- ;} if (j> 20 &&j < 24) { if (X()&1) break ; }}for(;j <25;j++){for (z =i ; z<= c;) G(z ++ , j , 3, X()&3?t[ w ] [ 3 ] :t[ w ] [2 ] ); i-=X()%7+6;c+=X () %7+6; } for(z= 0; z<4 ;z ++ ){ c =z * 8 + X ( )%5+2;a[z]=(int)(x+ 25 * cos ( (PI*c)/32)+z*2); b [ z]=(int)(y- 10 *sin(( PI* c ) /32)+2); for ( c = 0 ;c<4;c++){i=X()%3-1+(x +a[ z])/2+z;j=X()%3 -1+(y+b[z ]) /2 ;F (X( ) %3-1+a[z ] ,X ()% 3-1+ b[z ], i ,j,3 ,c-1?t [w] [1]:t[w][0]);F(x+ z* 2, y ,i,j,3,c-1 ?t[w][1]:t[w ][0]);}}for (x=0 ;x<4;x ++){ for ( y = 0;y++ <40;){if(X( )&1){u=(5-y)*PI/64;G(a[x]+( int )(14*cos (u)) ,b[ x]-(int) (7 * sin (u)) ,1 ,t[w ][ 4 ]);}}}for (x=0;x<4;x ++ ){for (y=0; y ++ < 512;){u=y*PI /256;v= (X( )&4095)/300 ;c= X( ) &7; G(a[ x] + ( int )(v*cos(u)),b[x]+(int)(v*sin(u )*.4),c?1 : 2,c? t[w][5]:t[w][6]) ; }}}void I (void ){i=x =X( ) %14+ 31 ; y=X ()%6 +12;c= x+ 7; for (j=y; j<25;j ++) {F (c-( c-i)/3,j,c ,j,3,t[w][0]);F(i,j, c, j,3,t[w][1]);if((z=X () )& 3) {if(z&4){i--;if(z&8)c--;}else{c++;if(z &8)i++ ;}if( c-i<4)z=(z& 1)?i--: c++;if (c-i>15 )z =(z& 1)? i ++ : c --;}if(j>20 && j< 24){ if (X( )&1)break;}}for ( ;j<25;j++ ) {for(z=i;z<=c;)G(z++,j, 3,X ()&3 ?t[w ][3] :t [w] [ 2 ] ) ; i -=X ( ) % 7+6;c +=X ()%7+6;}for(i=0;i<4;){c=i* 8+X () %5+2;a[i ]=(int )(x+25*cos((PI*c)/32 ) +i*2); b[i ++]= ( int ) ( y - 10 * sin ( (PI*c)/32) + 2) ;}for (i=0;i<4;i++){for(j =0;j++ <32 ;){u=PI*( X()% 256)/128;k=X()%8; G ((int)(k*cos ( u ))+ a[i ] +i *2 + X () % 2, (int )(k * sin(u)/2)+b[i],1,t[w][5]);}}for(i=0 ;i<4 ;i++ ){F (a[i],b[i] ,x+i*2,y,3,j?t[w][1 ]: t[w] [0]);for( j=0; j++< 3; ){ u= PI * (X() %256 )/128 ;k =X()% 4+6;F ((int)( k *cos(u))+a[i],(int)(k*sin( u) /2)+b[ i],x+i*2,y,3,t[ w][1 ] );}} for ( i= 0; i< 4; i ++ ){for ( j=0;j ++ < 40;){if( X()&1 ){u=(5 - j)*PI/64 ;G( a[i] +( int )( 14*cos( u)),b[i]-(int)(7*sin(u)),1, t[w][4]) ; } } }for(i= 0 ; i<4;i ++){ for(j=0;j++<512 ;) { u=j * PI / 256;v =(X() &4095 ) / 300 ; G(a [i]+(int)(v* cos (u)),b[i] + (int)(v*sin( u) / 2 ) ,1, t[w][ 5]);}}} void J(void){x=(X( )% 16 )+32;y=( X( )% 2)+4;z =( X ( )%16 )+32;for(i= 5;i > 2 ;i -- ) F ( x+( i/3) , y,z+ i,24 ,3,t [ w] [0] );for (; i> -5 ;i --)F (x+(i/ 3) ,y ,z+i, 24 ,3,t [w][1 ]);for(j=0; j< 21; j++ ){i=3*(j<10?j:j-6)+1 ;if (X ( )&1 )G (x+(j*(z -x) )/ (24 -y) +i /2-X() %i, j, 2,t[w][ 6 ]); for(k=0;k++< i; )G ((c=x+(j*(z- x ) )/(24-y) +i/ 2 )- X( )% i-1 ,j, 1 ,t[w] [5 ]); for(; i> - 1;i --){if(X() & 3 ) G ( c - i ,j ,1 ,t[w ] [4]);}}} void K(void ) { if(!(z=X()&1)){a[ 0]=X() %10 + 35 ; b[ 0 ]= X( )%4+9;a[ 2 ] =X ()%10+35 ; x = 16 ;y =11 ; } else {a[0]=X() %8+16;b[0]= X( ) %4 + 10;a[1]= X() %8+46; b[1] =X( )%4 + 10 ;a[2]=X() %8 + 16 ; a[ 3]=X ()% 8+ 46 ; x = y =10 ; } for ( ; z >= 0;z --){for(i=4 ;i>2;i --)F( a [z]+( i/3) ,b [ z] ,a [z+2] +i , 24 , 3, t[w][0 ]); for (; i > -4 ;i -- )F (a[ z ]+( i /3), b[z],a[z+2]+i,24,3,t [ w ][ 1] ); u=atan2 (24 -b [z] , a[z] - a [ z + 2]);v= sin( u);u=cos(u); for ( k =0; k < 256 ; k ++){if ( X ()&1)continue ;p=x*sin( k *PI/ 128);q =((k< 192 &&k>64 ) ?3* y :y ) *cos (k* PI /128);i =(int ) ( p *v- q *u ) +(a[ z ] + a[z+ 2]) /2;j= ((int )(p*u+q*v ) + b [z]+24 ) /2 ;G( i , j, 1, (k > 96 && k< 224) ? t [ w ] [5]: t [w] [ 4] ); } for( k =0;k< 256;k ++){p =x* sin(k*PI/128 ) ;q =(( k <192 && k> 64 )?3 * y : y )* cos (k *PI/ 128 );i=( int ) ( p *v-q*u)+ (a[ z ] +a[z+2] )/2; j =( (int )(p*u+q * v)+b [z ]+24) /2 ;for (c = 0;c ++<8;) { p =(X ( )%32 ) / 32.0 ; if ( X( ) &7) G( i- (int )(p*(i-(a [z]+a[z+2])/2 )) ,j-(int)( p *(j - (b [z]+ 24 )/ 2) ) ,1 , X( )% 4 ?t [ w ] [ 5 ]:t[w] [ 4 ]) ; else G(i - (int)(p*(i-(a[z]+a[ z+2])/2)),j-(int)( p* (j - ( b [z]+ 24 ) / 2 )) , 2, t [ w] [ 6] );} }}}void L ( void ){ if (! g){for(k=0 ;k<400 ;)m[1 ][ k++]=0;}else if ( g== 15){ for ( j=k = 0;j < 20; j ++ ) { for ( i=-10 ; i< 10 ; i ++ )m [1 ][k++] = ((i+0.5)*(i+0.5) + (j-9.5 ) *(j -9.5))<= 90.25 ?1 :0;}}else {; for (i = 0 ;i < 400;) m [1 ][i ++]= 0;if(g< 15) { u= ( 15-g) / 7.5 -1;v=1;}else{u=-1 ;v=(30 - g) / 7.5-1;}for(j=0;j<20;j ++){x =(int )(u* sqrt ( 90.25- (j-9.5 )* ( j -9.5))) +10 ; c = ( int )(v*sqrt( 90.25-(j-9.5)*(j-9.5)))+ 10 ; for(i=x; i<= c ; i++)m [ 1 ] [j*20+ i] =1 ;} } for ( j =0;j<5;j ++) {for(i= 0 ; i<10 ;i ++) { k=j*80+ i*2 ;x=m[1][k]+m[1 ] [ k+ 1]+m[1][k+20]+ m [1][k+21];c = m[1][k + 40] +m [ 1] [ k + 41 ] + m [ 1 ][ k +60 ] + m[ 1][k+ 61 ];_0 [j ][ i ]=!(x+c)?0:((x>c)?((r[ x]<<12)|(r[c] <<8 )|220):((r [c]<<12 )|(r[x] <<8) |223 ) ) ;} } h= - 96 ; } void M( void ){ for (i =e=0;i < 2000;) m[0][ i++]=(m[1][i]=0)-1;B(); if((i=X() )&3 ){ if ( i& 4)H();else I();}else {if ( i & 4 ) J ( ) ; else K (); } }void N( void ) {for(k= 1024 ;k>0;k/=2){do{for(i=j=0;i<e-k;i++ ) { if ((n [d[i ].y] + d [ i].x ) > ( n[ d [ i+ k]. y]+d[i +k ].x ) ){Z (p,i,i+k);Z(x,i,i+k);Z(y,i,i+k);Z(q,i,i+k);}}}while(j) ;}for(i=j=k= 0;i< e;i ++){for (; + j < + 2000 && (m[ 2 ][ j ]& 255 ) == 32 ; j++);d[i].q|=(j==2000)?l[X()%3]:(m[2][j++]&255);d[i] .u =X( )%128 +1; d[i].v=X() % 128 + 128 ; } for (; !k||(i- e < 16); i ++){for(;j< 2000 &&(m[2][j]&255)==32;j++);d[i].y=d[i].p=0;d[i].q =( X()&1? t[w][7]:t[ w] [ 8] ) | ((j== 2000 ) ?k =l[X( )%3]:(m[2][ j++ ]&255));d[i].u =-1999;}f=i-e;e=i;for(k=f/2;k;k-- ){ for (i=e -1 ; i> 0;i--){Z(p, i,i - 1) ; Z(x,i,i - 1);Z( y,i , i-1); Z(u,i,i-1);Z(v,i,i-1);Z(q,i,i-1);}}for(i=0;i<e;)d[i++].i= n[d[i].y ] +d [i].x;}void O(void){if(j== + 31)j= 1;g=(_1[(k+1)%19]+ j+_2[i- 1])%30;}void P(void){for( i=0;i <e;i++){if(d[i].u<0||d[i ].v> ( 25<<8)){d[ i ] .i=(X()%32)+ 4;d[i].j= (X()%32)+ 8;if(X()&1){d[i].u =X()%1280;d[i].v=-512;}else{d[i].u=1296;d[i].v=X()%6400;}}}}void R(void){ d[i].x=d[i].u>>4 ;d[i] .y=d [i].v>> 8;if(d[i].y>=0&&d[i].y<25&&d[i] .x>=0&& d[i].x<80){x=n[d[i].y]+ d[i].x;m[0][x]=((m[0][x] &4095)&&(m[0][x] &- 4096)) ?(m[0][ x]&-4096)|2048|d [i].q: d[i].q;}d[ i] .u -= d[ i].i;d[i].v+=d[ i].j;}void S(void){if(d[i].u){if(d[i].v){d [i].v-- ; m[0][ d[i].i]=(d[ i].q&255)|((X()%128>d[i ].v )?-2304: -256);}else{d[i].u--;m[0][d[i].i]=(X()%128>d[i].u)?((X()&3)?d[i].q:d[i].q^256 ):((d [i].q& 255)|-2304);}}else{m[0][d[ i ]. i] =X()&3?d[i].q: d[i] .q^ 256; }} void T(void){if(d[i ].u){if(d[i].v) {d[i].v--;m[0][d[i]. i]= (d[i].q& 255 )|(( X()% 128>d [ i] . v)?- 2304 :- 256);} else { d [i] .u --; m[0 ][d[i].i]= (X()%128>d[i].u) ?((X()&7)?d[i].q:d [i].q^2048):((d[i].q&255 ) |-( 4+ 2300)) ;}}else {m [ 0] [ d[ i]. i]=( X()&7)?d[i].q:d[i].q^2048;}}void U(void){k=h>>3; for (i= 0;i <10;i ++){if(k + i >=0 && k+i< 80 ) { for ( j = 0 ;j < 5 ;j++ )m[0 ][n[j+2]+i+k]=_0[j][i];}}if(h++>656)h=-96 ;} void V (void ){if(d[i].u ) { if (d [ i]. v ){d [ i ]. v -- ;m [ 0][d[i].i]=(d[i].q&255)|((X()%128>d[i].v)?-2304:-256); } else {d[i].u--;m[0 ][d[i ] . i ] = (X() % 128 >d[ i ]. u) ?d[i ] . q: ( (d [i].q&255)|-2304) ;}}else{;m[00][d[i].i]=d[i].q;;} } void Q (void ){for (i = 0 ; i< 2000;)m[ 0 ][ i++ ]= 0; U ();for(i =0;i<e;i++){if (d [i].p&1){ if(d[i].p&2)V();else T() ; }else{if(d[i].p&2) S ( );else R( ); } } B ( ) ;} void E(void ) {C();for(i=c=0;i<2000;)m[1][i++]=0;for(i=0;i<e;i++){if( d[i] . p){d[i].u=d[ i ] .v =0 ; d[i] . q = ( d[i] .p == 3? ((d[ i ] . q&-32768)?-2304:32512) :((d[i].q&-32768)?30720 :- 30976))|( d [i] . q& 255 ); } } if ( X ()&1){c++ ;p =1 ; }else{p=0;}A();for(f=1; f; ){if(kbhit()){if(c<3+(int) p ){;C();A(); ; } else { break ;} }else { Q ();}for ( i =f= 0;i<e; i ++){ if( !d [i].p){if( d[i].u>=0&&d[i].v<6400 )f++ ;else d [i].i =d [ i ].j = 0;}}}for (i = 0; i< 2000 ;){d[i].u=d[i].x <<4;d[ i++].v=d[i].y<<8;}for(i=0 ; i< 2000 ; )m[0] [i++]= -1;B ( ) ; for (k =1;k ;){for(i=0;i<2000;)m[0][i ++ ]=0;U();for(i=k=0;i<e ;i ++ ){if( d[ i ] .p){ d [ i]. x =d[i ].u >> 4;d[i]. y=d [i ].v>> 8;if(d[i].y>=0&&d[i].y<25&&d[i] .x >=0 && d [ i ]. x < 80 ){k ++; m [ 0 ] [n[ d[i].y]+d[i].x]=d[i]. q;if( !(j=m[1 ][d[i].i])){d[i].v+= 64 ;} else { d[ i ]. u+= a [ -- j ] ; d[i].v+= b [j];}}}}B() ;if( kbhit ()){C();break;}}if(p>0)c= + c-1 ;} void W( void ) { for ( i = e = 0; i <2000;i++){if( (m [2][i]&255)!=32||(m[2][i]&-4096)){d[e]. u = X ()% 4+ 2;d[e ] .v= X() % 6 + 2 ; d[ e]. i=X()%32+20;d[e].j=X()%8;d[e].x =(i%80)<<d[e].u;d[e].y = ( i / 80 ) <<d [ e ] .v ; d [e ++ ] .q=m [2][i];}}for(f=1;f&&!kbhit ();){for(i=f=0;i<2000;)m[0] [i ++]=0 ; for ( k= e-1 ; k >= 0 ;k -- ){if(d [ k ].i){f ++ ;i=(d[ k] .x+(j=d[k].i*d[k].i))>>d[k]. u; j=(d [k ].y- (d[ k ] .j ? j: 0 )) >> d[ k] . v ;if(j>=0&&j < 25&&i>=0&&i<80)m[0][n[j]+i]=d[k]. q ;if (! (-- d [k]. i ) ) d [ k ] .j= n[d[k ] .y>>d[k].v]+(d[k].x>>d[k].u);}else{m[0][d[k].j ] =d[ k ] . q ;} }B() ; } if( kbhit( ) )C () ;for(i=0;i<2000;)o[i++]=m[2][i];}void/*E! / SY! */ cdecl main ( void ) {_5 =* _3; j=-80 ;for (i=0;i< 25 ;)n[i++]=j+=80;_asm{; _asm mov ax, 1003h _asm xor bx , bx _asm int 10h _asm mov ah,2ah _asm nop; _asm int 21h _asm mov k ,cx _asm mov j,dx }i=j >>8;j&=255;O();w=(g >=14 && g<= 16 )?1 :0;L( ); D(); do{;M();N();while(! kbhit ( ) ) { Q();P();}E();}while (c <=1);W();/* 7/26 */ _asm{_asm mov ax,1003h _asm xor bx,bx _asm nop; _asm inc bx _asm int 10h}} |