首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

hdu3094 A tree game-树的删边游戏

2012-09-16 
hdu3094A tree game----树的删边游戏A tree gameTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32

hdu3094 A tree game----树的删边游戏

A tree gameTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 314    Accepted Submission(s): 146


Problem DescriptionInputOutputSample InputSample OutputSourceRecommend#include<iostream>#include<cstdlib>#include<stdio.h>#include<memory.h>#include<vector>using namespace std;vector<int>v[100005];int dfs(int x,int pre){ int ans=0; for(int i=0;i<v[x].size();i++) { //printf("%d %d %d \n",x,i,v[x][i]); if(v[x][i]!=pre) { ans^=(1+dfs(v[x][i],x)); } } return ans;}int main(){ int t,a,b,n; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) v[i].clear(); n--; while(n--) { scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } //printf("%d\n",v[1][2]); if(dfs(1,-1)) puts("Alice"); else puts("Bob"); }}

热点排行