Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的这个程序怎么wa#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator