| 
 | 
back to boardWhat's wrong?? Posted by  Sega 6 Aug 2003 13:19 This is my program:   #include<iostream.h>   int **a,*b,n,f=0,c[2]={0};   void dfs(int k,int t) {     int i;    b[k]=t; c[t]++;     for (i=0; i<n; i++)     {         if (a[k][i])         {             if (b[i]==-1)                 dfs(i,(t+1)%2);             else if (b[i]==b[k])             {f=1; break;}         }     } }   int main() {     int m,i,j,fir,sec;     cin >> n >> m; n*=2;     a=new int* [n];     b=new int [n];     for (i=0; i<n; i++)     {         a[i]=new int [n]; b[i]=-1;         for (j=0; j<n; j++)             a[i][j]=0;     }     for (i=0; i<m; i++)     {         cin >> fir >> sec;         fir--; sec--;         a[fir][sec]=a[sec][fir]=1;     }     for (i=0; i<n; i++)         if (b[i]==-1) dfs(i,0);     if (c[0]!=c[1]) f=1;     if (f) cout << "IMPOSSIBLE";     else     {     for (i=0; i<n; i++)         if (!b[i]) cout << i+1 << ' ';     cout << endl;     for (i=0; i<n; i++)         if (b[i]) cout << i+1 << ' ';     }     cout << endl;
      return 0; } Check, what is wrong there, please. Try this simplest test (+) 1 0 Re: Try this simplest test (+) Posted by  Sega 7 Aug 2003 22:45 Many thanks  |  
  | 
|