2010-02-09 53 views
3

這不是一個家庭作業問題,而是我打算知道這是如何學習編程。我保持登錄到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看看我能不能做東西。

謝謝。

回答

5

你應該從更簡單的問題開始。嘗試尋找地區,甚至從當地的學校比賽中解決問題。 您需要從數據結構到算法的大型編程。掌握一種基本的編程語言,即答案被接受。

+2

更容易的問題?這個問題集是代碼堵塞 – JPro 2010-02-09 10:52:16

+4

中的第一個問題,這裏是一個簡單的(r)問題,將羅馬數字中的阿拉伯數字(例如:X中的10,2010)轉換爲MMX,然後將這個反轉的羅馬字符轉換爲阿拉伯文XLIX到49 – Pentium10 2010-02-09 11:28:04

+0

@ Pentium10 This是一箇舊帖子,但我的問題有點類似於OP,我可以理解這個問題,但我不知道在哪裏/如何開始解決它。所以一般我關注什麼?我是否錯過像NLP這樣的知識?機器學習?或某種CS理論(我不是大學畢業生)或者這只是簡單的算法設計和數學?學習像編譯器設計這樣特定的東西有幫助嗎? – gideon 2012-02-07 04:51:34

2

你不能通過比賽來開始學習編程。如果你根本不知道任何編程,你會寫的第一個程序是諸如「hello world」,斐波那契和阿克曼等。從TopCoder這樣的東西開始就像學習駕駛一輛一級方程式賽車一樣。它不這樣工作。

1

你是非常正確的JesperE。 JPRO,回到基礎,並從那裏解決。你的競爭並贏得比賽的編程能力僅取決於兩件事情:

  1. 你正在使用的語言的深刻理解和
  2. 你的語言心理彈性。
14

從困難的問題開始是一個很大的錯誤。許多世界總決賽的問題對於很多有經驗的程序員來說太難了,所以毫不奇怪,對於新人來說這也太難了。

正如其他人所說,從更簡單的問題開始。我假設你知道編程的基礎知識,並且可以用至少一種編程語言編寫代碼。嘗試TopCoder上的Division-2問題集和ACM ICPC的區域/資格輪次的問題。從SPOJ,UVa和Project Euler等網站上找到簡單的問題(網上有簡單問題清單)並解決它們。在你解決的同時,還要閱讀算法和計算機科學的基礎知識。TopCoder是一個很好的資源,因爲它們有很多教程和文章,還允許您查看其他人的解決方案。

恕我直言,成爲一個更好的程序員一般需要大量的練習研究。沒有捷徑。你不能認爲你是某種英雄程序員,可以跳入並解決所有問題。你必須接受的是,還有很長的路要走,並從一開始就開始。

+3

+1項目euler非常有幫助,從而開始進入這種數學/算法問題。 – gideon 2012-04-11 08:45:07

2

過去一週左右我一直在工作Google Code Jam問題,我認爲他們是很棒的練習。關鍵是要找到一些可以擴展你的能力的問題,但不是那些讓你想放棄的問題。谷歌代碼Jam問題範圍廣泛的困難!

我建議先從下的那些「我應該在哪裏開始」的位置:

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

然後探討所有比賽的第1輪的問題。如果這些太容易移動到其他回合。

我真的很喜歡代碼堵塞的事情,你可以使用幾乎任何你想要的語言,並且你可以從他們的自動判斷中得到反饋。如果您用完Code Jam問題,請查看其他人提到的其他網站。

1

閱讀問題解決問題拉爾森。 這是數學,但我覺得它非常有用的解決算法問題。