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

我有一个简单的想法,大家看看

Posted by Algor at 2010-03-02 01:14:18 on Problem 1637
/*1.存在邻接边为奇数的点必不能构成欧拉回路*/
/*2.任一点的入度和出度不能大于这点总邻接边的一半*/
/*3.满足上述条件的就能通过指定双向边的方向构成欧拉回路*/
/*上述看法有错吗?如有,举个反例*/
#include<iostream>
using namespace std;
#define N 202
int in[N],out[N],edge[N],v;
bool Euler()
{
	int i;
	for(i=1;i<=v;i++){
		if(edge[i]%2)//1
			return false;
	}
	for(i=1;i<=v;i++){
		if(!((out[i]<=edge[i]/2)&&(in[i]<=edge[i]/2)))//2
			return false;
	}
	return true;//3
}
int main()
{
	int t,i,e,fr,to,dr;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&v,&e);
		for(i=1;i<=v;i++)
			edge[i]=in[i]=out[i]=0;
		for(i=0;i<e;i++)
		{
			scanf("%d%d%d",&fr,&to,&dr);
			if(dr){
				out[fr]++;
				in[to]++;
			}
			edge[fr]++;
			edge[to]++;
		}
		if(Euler()) printf("possible\n");
		else printf("impossible\n");
	}
	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