首页 > ACM题库 > HDU-杭电 > Hdu 1567 2006 待解决 [解题报告] C++
2013
12-12

Hdu 1567 2006 待解决 [解题报告] C++

2006

问题描述 :

When the old year is leaving and the New Year is coming, people are always looking back over the past while looking forward to the future.

"What do you think is the most important events in the past year 2006?", a friend asked me.

"Well, maybe the World Cup.", I replied.

"Yeah, do you know, in a football match, how to arrange a proper match table for a group?"

"That’s easy. In the World Cup, there are only 4 teams in a group. Everyone knows how to do it."

"Yes, it’s easy for four-team’s arrangement. But if there are six teams or more games, can you arrange that?"

"OK, let me have a try". I answered.

In fact, I tried many times to solve the problem, but got failure in the end. Can you help me?

输入:

The input contains data for several test cases.

Each case contains a single even integer, which is less than 2007, indicate the number of teams in a group.
and n-1 lines followed, indicate the match table.each line indicate one round in the contest.For example,
4
1-2 3-4 // the first round
1-3 2-4 // the second round
1-4 2-3 // the third round

输出:

For each test case output "Yes" means the match table is correct, or "No" otherwise.

样例输入:

2
1-2
4
1-2 3-4 
1-3 2-4 
1-4 2-3 
4
1-3 2-4 
1-2 3-4 
1-4 2-3 
4
1-2 3-2 
1-3 2-4 
1-4 2-3

样例输出:

Yes
Yes
Yes
No


  1. 第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。

  2. 在方法1里面:

    //遍历所有的边,计算入度
    for(int i=0; i<V; i++)
    {
    degree = 0;
    for (j = adj .begin(); j != adj .end(); ++j)
    {
    degree[*j]++;
    }
    }

    为什么每遍历一条链表,要首先将每个链表头的顶点的入度置为0呢?
    比如顶点5,若在顶点1、2、3、4的链表中出现过顶点5,那么要增加顶点5的入度,但是在遍历顶点5的链表时,又将顶点5的入度置为0了,那之前的从顶点1234到顶点5的边不是都没了吗?

  3. 嗯 分析得很到位,确实用模板编程能让面试官对你的印象更好。在设置辅助栈的时候可以这样:push时,比较要push的elem和辅助栈的栈顶,elem<=min.top(),则min.push(elem).否则只要push(elem)就好。在pop的时候,比较stack.top()与min.top(),if(stack.top()<=min.top()),则{stack.pop();min.pop();},否则{stack.pop();}.

  4. L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-1])这个地方也也有笔误
    应改为L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-2])

  5. 第一句可以忽略不计了吧。从第二句开始分析,说明这个花色下的所有牌都会在其它里面出现,那么还剩下♠️和♦️。第三句,可以排除2和7,因为在两种花色里有。现在是第四句,因为♠️还剩下多个,只有是♦️B才能知道答案。

  6. “可以发现,树将是满二叉树,”这句话不对吧,构造的树应该是“完全二叉树”,而非“满二叉树”。