POJ 1041 John & amp; #39; s trip (Euler loop)

Source: Internet
Author: User

POJ 1041 John & #39; s trip (Euler loop)

Address: POJ 1041

The question must be a Lexicographic Order. Therefore, you must first sort the edge number so that each time you traverse the vertex with a smaller edge number. It is more convenient to use vector.

The Code is as follows:

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include #include 
     
      #include 
      #include 
       
        #include 
        
         using namespace std;#define LL long long#define pi acos(-1.0)const int mod=1e9+7;const int INF=0x3f3f3f3f;const double eqs=1e-9;const int MAXN=2000+10;int stk[2000000], deg[2000000], tot, vis[2000000];vector 
         
           >vec[MAXN];void add(int u, int v, int id){ vec[u].push_back(make_pair(id,v)); vec[v].push_back(make_pair(id,u));}void dfs(int u){ for(int i=0;i
          
           0) puts("Round trip does not exist."); else{ for(i=1;i<=n;i++){ if(vec[i].size()) sort(vec[i].begin(),vec[i].end()); } dfs(1); if(tot
           
            =0;i--){ printf("%d",stk[i]); if(i) printf(" "); } printf("\n"); } } } return 0;}
           
          
         
        
       
     
    
   
  
 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.