经典指数          
原因
1657
浏览数
0
收藏数
 

#include #include using namespace std; const int SIZE=100; int n,m,r[SIZE]; bool map[SIZE][SIZE],found; bool successful( ) {     int i;     for(i=1;i<=n;i++)         if(!map[r[i]][r[i%n+1]])             return false;     return true; } void swap(int *a,int *b) {     int t;     t=*a;     *a=*b;     *b=t; } void perm(int left,int right) {     int i;     if(found)         return ;     if(left>right)     {         if(successful( ))         {             for(i=1;i<=n;i++)                 cout<>n>>m;     memset(map,false,sizeof(map));     for(i=1;i<=m;i++)     {         cin>>x>>y;         map[x][y]=true;         map[y][x]=true;     }     for(i=1;i<=n;i++)         r[i]=i;     found=false;     perm(1,n);     if(!found)         cout<<"No solution!"<

     举报   纠错  
 
切换
暂时还没有答案,欢迎分享你的解答 . . .
撰写答案
扫描后移动端查看本题