50 条题解
- 
  0陌离 LV 3 @ 2008-11-10 23:28:46 编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 0ms
 ├ 测试数据 08:答案正确... 25ms
 ├ 测试数据 09:答案正确... 103ms
 ├ 测试数据 10:答案正确... 25ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:153ms貌似算快的说~~~~ var edge:array[1..400000,1..2]of longint; 
 l,q,s,p,g,f:array[1..200000]of longint;
 ans,b,c:array[1..200000]of boolean;
 i,j,x,y,n,m,r,t:longint;procedure addedge(x,y:longint); 
 begin
 inc(m);
 edge[m][1]:=y;
 edge[m][2]:=l[x];
 l[x]:=m;
 end;begin 
 fillchar(p,sizeof(p),0);
 fillchar(l,sizeof(l),0);
 fillchar(b,sizeof(b),true);
 fillchar(c,sizeof(c),true);
 fillchar(g,sizeof(g),0);
 m:=0;
 readln(n);
 for i:=1 to n-1 do
 begin
 readln(x,y);
 addedge(x+1,y+1);
 addedge(y+1,x+1);
 inc(p[x+1]);
 inc(p[y+1]);
 end;
 r:=0;
 for i:=1 to n do
 if p[i]=1 then
 begin
 inc(r);
 q[r]:=i;
 g[i]:=1;
 c[i]:=false;
 end;
 i:=1;
 m:=0;
 while i0 do
 begin
 if (p[edge[t][1]]>0)and(c[edge[t][1]]) then
 begin
 dec(p[edge[t][1]]);
 f[q[i]]:=edge[t][1];
 break;
 end;
 t:=edge[t][2];
 end;
 if (i=r)and(r
- 
  0@ 2008-11-10 20:58:52编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 9ms
 ├ 测试数据 08:答案正确... 119ms
 ├ 测试数据 09:答案正确... 119ms
 ├ 测试数据 10:答案正确... 150ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:397mstree dp 唉!不能秒杀! 
 唉
 考试的时候没能ac楼下的捕龟者比我还快!!!!!!!! 死下无面 
- 
  0@ 2008-11-10 15:25:34编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 150ms
 ├ 测试数据 08:答案正确... 509ms
 ├ 测试数据 09:答案正确... 353ms
 ├ 测试数据 10:答案正确... 728ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:1740ms树形DP 前向星构树(边得全部双向翻倍否则WA你没商量) 求出中心点后用DP过程中的深度求最长路径 
 150行的程序太折磨人了 开始没碰上puppy还TLE了1个点
 还好AC了。。。ms大家大都用的是3次dfs的方法?
- 
  0@ 2008-11-09 12:00:57比赛的时候数组开小了.. 
 刚刚又没看因为数组WA了好多次..
 编译通过...
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 0ms
 ├ 测试数据 08:答案正确... 119ms
 ├ 测试数据 09:答案正确... 41ms
 ├ 测试数据 10:答案正确... 103ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:263ms
 三次DFS..
 没过的试下这个数据
 17
 0 1
 1 2
 1 3
 1 4
 4 5
 5 10
 5 6
 6 7
 6 8
 6 9
 4 11
 11 12
 12 13
 11 14
 14 15
 14 16
 答案是
 4
 5
 6
 7
 8
 9
 11
 12
 13
 14
 15
 16
- 
  0@ 2008-11-09 11:21:37编译通过... 
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 384ms
 ├ 测试数据 08:答案正确... 744ms
 ├ 测试数据 09:答案正确... 838ms
 ├ 测试数据 10:答案正确... 978ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:2944ms
- 
  0@ 2008-11-09 11:05:23昨天DFS居然没调出来.. 
 看来真的是菜到家了..感觉和树网的核类似嘛.. 
- 
  0@ 2008-11-09 10:58:29第22个 
 一次 AC,只要扫2遍,我却扫了3遍,不过第一遍只取了1个
 AC率被我从12%升到13% ^-^
 编译通过...
 ├ 测试数据 01:答案正确... 0ms
 ├ 测试数据 02:答案正确... 0ms
 ├ 测试数据 03:答案正确... 0ms
 ├ 测试数据 04:答案正确... 0ms
 ├ 测试数据 05:答案正确... 0ms
 ├ 测试数据 06:答案正确... 0ms
 ├ 测试数据 07:答案正确... 119ms
 ├ 测试数据 08:答案正确... 322ms
 ├ 测试数据 09:答案正确... 322ms
 ├ 测试数据 10:答案正确... 322ms
 ---|---|---|---|---|---|---|---|-
 Accepted 有效得分:100 有效耗时:1085ms
- 
  0@ 2008-11-09 10:15:49教主前面直接copy我的题解 orz 
- 
  0@ 2008-11-09 09:34:05我是来 orz 教主的。。。 
- 
  0@ 2008-11-09 09:17:42Orz教主…… 
- 
  0@ 2008-11-09 08:47:35这题和去年NOIP第四题一样的吧?DFS就好。 
- 
  0@ 2008-11-09 08:44:00这题我用的前向星存储,然后对树进行3遍DFS即可~~~~ 树结构中 前向星=无敌=AC 
- 
  0@ 2008-11-09 07:34:39我哭死了,昨天9:31做完,没交上去! 
 今天1次AC!
- 
  0@ 2008-11-09 02:13:12占座…… 
- 
  0@ 2008-11-06 21:04:54地下室。。 
- 
  0@ 2008-11-06 12:22:51zhan lou 
- 
  0@ 2008-11-06 12:21:26HOHO~~ fengyi的std怎么?难不成不是std? 
- 
  -1@ 2009-09-27 16:11:07一次秒杀了 
- 
  -1@ 2009-09-14 18:40:04这道题不是树结构么... 
- 
  -1@ 2009-07-20 19:41:41treeDP写起来好爽,不过好慢..