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 1176. Hyperchannels

I always get WA. Can someone give me a test? This is my program.
Posted by Metal King 20 Mar 2003 23:47
#include <stdio.h>
#include <stdlib.h>

#define N 1050

#define setbit1(x,y) ( a[x][y >> 3] |=  (1 << (y & 7)) )
#define setbit0(x,y) ( a[x][y >> 3] &= ~(1 << (y & 7)) )
#define getbit(x,y)  ( a[x][y >> 3] &   (1 << (y & 7)) )

int n, s, x, lev;
int a[N][N/8], d[32010];

void read ()
{
   int i, j, v, x = 0;

   //freopen( "1176.in", "rt", stdin );
   scanf( "%d%d", &n, &s );
   for ( i = 1; i <= n; i++ )
       for ( j = 1; j <= n; j++ )
       {
          scanf( "%d", &v );
          if ( !v && i != j )
             setbit1( i, j ), x++;
       }
   if ( !x ) exit( 0 );
}

void ciclu (int s)
{
   int j;

   lev++;

   for ( j = 1; j <= n; j++ )
       if ( getbit( s, j ) )
       {
          setbit0( s, j );
          ciclu( j );
       }

   d[++d[0]] = s;
/*   if ( !x || lev == 1 )
      printf( "%d ", s );
   else
      printf( "%d\n%d ", s, s );
   x = s;

   lev--;*/
}

int main ()
{
   int i;

   read();

   ciclu( s );
   for ( i = 1; i < d[0]; i++ )
       printf( "%d %d\n", d[i], d[i + 1] );

   return 0;
}