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

Output Limit Exceed!?那位大虾帮忙分析一下阿……

Posted by 123dc4567 at 2006-09-10 15:08:26 on Problem 2230
#include<stdio.h>
#include<iostream>
using namespace std;
struct node
{
	int v;
	bool visit;	
};
vector<struct node>*g;
void dfs(int v)
{	
	for(vector<struct node>::iterator itr = g[v].begin();itr!=g[v].end();itr++)
	{
		if(itr->visit)continue;
		itr->visit = true;
		dfs(itr->v);		
	}
	cout<<v<<endl;
}
int main()
{
	freopen("in.txt","r",stdin);
	int m,n,i,j,k;
	cin>>m>>n;
	g = new vector<struct node>[m+1];
	struct node temp;
	temp.visit = false;
	for(i = 0;i<n;i++)
	{
		cin>>j>>k;
		temp.v = j;
		g[k].push_back(temp);
		temp.v = k;
		g[j].push_back(temp);
	}
	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