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 123dc4567 at 2006-09-10 15:10:54 on Problem 2230
In Reply To:Output Limit Exceed!?那位大虾帮忙分析一下阿…… Posted by:123dc4567 at 2006-09-10 15:08:26
#include<stdio.h>//链表练习!!
#include<iostream.h>
struct edge
{
	int v;
	bool visit;	
	struct edge* next;
};
struct edge * gg;
struct edge edges[100002];
int edgeN = 0;
void dfs(int v)
{	
	cout<<v<<endl;
	struct edge *q =gg[v].next;
	while(gg[v].next!=NULL)
	{
		int i = q->v;
		gg[v].next = q->next;
		dfs(i);
	}
}
int main()
{
	freopen("in.txt","r",stdin);
	int m,n,i,j,k;
	cin>>m>>n;
	gg = new struct edge[m+1];
	for(i = 0;i<=m;i++)
	{
		gg[i].next = NULL;
		gg[i].v = -1;
	}
	struct edge *temp;
	for(i = 0;i<n;i++)
	{
		cin>>j>>k;
		edges[edgeN].v = k;
		temp = gg[j].next;
		gg[j].next = &edges[edgeN];
		gg[j].next->next = temp;
		edgeN++;
		edges[edgeN].v = j;
		temp = gg[k].next;
		gg[k].next = &edges[edgeN];
		gg[k].next->next = temp;
		edgeN++;
	}
	dfs(1);
	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