能够解决谷歌代码堵塞问题集

时间:2010-02-09 10:45:23

标签: logic

这不是一个家庭作业问题,而是我打算知道这是否是学习编程所需要的。我保持登录TopCoder不是为了实际参与,而是基本了解问题是如何解决的。但据我所知,我不明白问题是什么,以及如何将问题转化为可以解决问题的算法。 刚才我正好看看在中国举行的ACM ICPC 2010 World Finals。团队得到了问题集,其中一个就是:

Given at most 100 points on a plan with distinct x-coordinates,
   find the shortest cycle that passes through each point exactly once, 
   goes from the leftmost point always to the right until it reaches the 
   rightmost point, then goes always to the left until it gets back to the 
   leftmost point. Additionally, two points are given such that the the path
   from left to right contains the first point, and the path from right to 
   left contains the second point. This seems to be a very simple DP: after 
   processing the last k points, and with the first path ending in point a 
   and the second path ending in point b, what is the smallest total length
   to achieve that? This is O(n^2) states, transitions in O(n). We deal 
   with the two special points by forcing the first path to contain the first 
   one, and the second path contain the second one.

现在我不知道在阅读问题集后我应该解决什么。

还有另外一个来自谷歌代码堵塞:

    Problem

        In a big, square room there are two point light sources: 
one is red and the other is green. There are also n circular pillars.

        Light travels in straight lines and is absorbed by walls and pillars. 
    The pillars therefore cast shadows: they do not let light through. 
    There are places in the room where no light reaches (black), where only 
    one of the two light sources reaches (red or green), and places where 
    both lights reach (yellow). Compute the total area of each of the four
     colors in the room. Do not include the area of the pillars.

        Input

            * One line containing the number of test cases, T.

        Each test case contains, in order:

            * One line containing the coordinates x, y of the red light source.
            * One line containing the coordinates x, y of the green light source.
            * One line containing the number of pillars n.
            * n lines describing the pillars. Each contains 3 numbers x, y, r. 
    The pillar is a disk with the center (x, y) and radius r.

        The room is the square described by 0 ≤ x, y ≤ 100. Pillars, room 
    walls and light sources are all disjoint, they do not overlap or touch. 

Output

For each test case, output:

Case #X:
black area
red area
green area
yellow area

是否需要计划的人应该能够解决这些类型的问题?

我很感激是否有人可以帮我解释谷歌代码堵塞问题集,因为我希望今年参与Code Jam,看看我是否可以进行对抗。

感谢。

7 个答案:

答案 0 :(得分:15)

从困难问题入手是一个很大的错误。对于很多有经验的程序员来说,许多世界总决赛的问题都太难了,所以对于一个新手来说这也太难了。

正如其他人所说,从更容易的问题开始。我假设您了解编程的基础知识,并且可以用至少一种编程语言编写代码。尝试在TopCoder上的Division-2问题集以及ACM ICPC的区域/合格轮次中遇到问题。找出SPOJ,UVa和Project Euler等网站的简单问题(有在线提供的简单问题列表)并解决它们。在您解决时,还要阅读算法和计算机科学的基础知识。 TopCoder是一个很好的资源,因为他们有很多教程和文章,也允许你查看其他人的解决方案。

恕我直言,成为一名优秀的程序员通常需要进行大量的练习学习。没有捷径。你不能假设你是某种英雄程序员,他可以跳进去解决所有问题。你必须承认还有很长的路要走,并从头开始。

答案 1 :(得分:6)

你应该从更简单的问题开始。尝试寻找地区,甚至从当地学校竞赛中获得问题。 您需要具有从数据结构到算法的一般编程的大视图。掌握一种基本的编程语言,即接受答案的语言。

答案 2 :(得分:3)

你不能通过比赛开始学习编程。如果您根本不知道任何编程,您将编写的第一个程序是“hello world”,fibonacci和ackermann。从像TopCoder这样的东西开始就像学习使用一级方程式赛车驾驶一样。它没有那种方式。

答案 3 :(得分:3)

简而言之,您必须了解一些用于解决此类问题的基本技术。了解动态编程,回溯算法,搜索等,可以在解决问题时为您提供帮助。

来自Google Code Jam的这个实际上非常难,并涉及计算几何算法。如何解决这个问题详见:http://code.google.com/codejam/contest/dashboard?c=311101#s=a&a=5

答案 4 :(得分:2)

过去一周左右我一直在处理Google Code Jam问题,我认为这些都是很棒的练习。关键是要找到能够稍稍提升你的能力的问题,但不是那些让你想要放弃的问题。 Google Code Jam问题范围广泛,难度很大!

我建议从这里的“我应该从哪里开始”开始:

http://code.google.com/codejam/contests.html

然后探讨所有比赛的第1轮问题。如果那些太容易移动到其他轮次。

我非常喜欢代码堵塞的事情是你可以使用你想要的几乎任何语言,你可以从他们的自动判断中获得反馈。如果您的Code Jam问题用完了,请查看其他人提到的其他网站。

答案 5 :(得分:1)

你是对的JesperE。 JPRO,回到基础并从那里解决它。你竞争和赢得编程竞赛的能力取决于两件事:

  1. 您对所用语言的深刻理解和
  2. 用语言表达你的心理灵活性。

答案 6 :(得分:1)

阅读Larson解决问题的问题。 它适用于数学,但我发现它对于解决算法问题非常有用。

相关问题