Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我的这个程序怎么wa

Posted by skogt at 2010-09-20 21:02:03 on Problem 1041
#include<iostream> 
#include<algorithm> 
using namespace std; 

int edge[2000][2]; 
int degree[50]; 
int ans[2000]; 
bool visited[2000]; 
int edgenum,top,start,maxnum; 

bool check() 
{ 
    for(int i=1;i<=maxnum;i++) 
        if(degree[i]%2!=0) 
        { 
            return false; 
            break; 
        } 
         
} 

void euler(int v) 
{ 
    for(int i=1;i<=edgenum;i++) 
    { 
        if(!visited[i]&&(edge[i][0]==v||edge[i][1]==v)) 
        { 
            ans[top++]=i; 
            visited[i]=true; 
            euler(edge[i][0]+edge[i][1]-v); 
        } 
    } 
} 

int main() 
{ 
    int x,y,z; 
    scanf("%d%d",&x,&y); 
    while(x!=0&&y!=0) 
    { 
        memset(edge,0,sizeof(edge)); 
        memset(degree,0,sizeof(degree)); 
        memset(ans,0,sizeof(ans)); 
        memset(visited,false,sizeof(visited)); 
        edgenum=top=maxnum=0; 
        start=min(x,y); 
        do 
        { 
            scanf("%d",&z); 
            edge[z][0]=x; 
            edge[z][1]=y; 
            degree[x]++; 
            degree[y]++; 
            edgenum++; 
            maxnum=max(maxnum,max(x,y)); 
        }while(scanf("%d%d",&x,&y)&&(x+y)); 
        if(!check()) 
            puts("Round trip does not exist."); 
        else 
        { 
            euler(start); 
            for(int i=0;i<top-1;i++) 
                printf("%d ",ans[i]); 
            printf("%d\n",ans[top-1]); 
        } 
        scanf("%d%d",&x,&y); 

    } 
    return 0; 
} 



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator