• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 74,  comments - 33,  trackbacks - 0
            The Troublesome Frog
            Time Limit: 5000MS Memory Limit: 100000K
            Total Submissions: 3595 Accepted: 1058
            Case Time Limit: 500MS

            Description

            In Korea, the naughtiness of the cheonggaeguri, a small frog, is legendary. This is a well-deserved reputation, because the frogs jump through your rice paddy at night, flattening rice plants. In the morning, after noting which plants have been flattened, you want to identify the path of the frog which did the most damage. A frog always jumps through the paddy in a straight line, with every hop the same length:

            Your rice paddy has plants arranged on the intersection points of a grid as shown in Figure-1, and the troublesome frogs hop completely through your paddy, starting outside the paddy on one side and ending outside the paddy on the other side as shown in Figure-2:

            Many frogs can jump through the paddy, hopping from rice plant to rice plant. Every hop lands on a plant and flattens it, as in Figure-3. Note that some plants may be landed on by more than one frog during the night. Of course, you can not see the lines showing the paths of the frogs or any of their hops outside of your paddy ?for the situation in Figure-3, what you can see is shown in Figure-4:

            From Figure-4, you can reconstruct all the possible paths which the frogs may have followed across your paddy. You are only interested in frogs which have landed on at least 3 of your rice plants in their voyage through the paddy. Such a path is said to be a frog path. In this case, that means that the three paths shown in Figure-3 are frog paths (there are also other possible frog paths). The vertical path down column 1 might have been a frog path with hop length 4 except there are only 2 plants flattened so we are not interested; and the diagonal path including the plants on row 2 col. 3, row 3 col. 4, and row 6 col. 7 has three flat plants but there is no regular hop length which could have spaced the hops in this way while still landing on at least 3 plants, and hence it is not a frog path. Note also that along the line a frog path follows there may be additional flattened plants which do not need to be landed on by that path (see the plant at (2, 6) on the horizontal path across row 2 in Figure-4), and in fact some flattened plants may not be explained by any frog path at all.

            Your task is to write a program to determine the maximum number of landings in any single frog path (where the maximum is taken over all possible frog paths). In Figure-4 the answer is 7, obtained from the frog path across row 6.

            Input

            Your program is to read from standard input. The first line contains two integers R and C, respectively the number of rows and columns in your rice paddy, 1 <= R,C <= 5000. The second line contains the single integer N, the number of flattened rice plants, 3 <= N <= 5000. Each of the remaining N lines contains two integers, the row number (1 <= row number <= R) and the column number (1 <= column number <= C) of a flattened rice plant, separated by one blank. Each flattened plant is only listed once.

            Output

            Your program is to write to standard output. The output contains one line with a single integer, the number of plants flattened along a frog path which did the most damage if there exists at least one frog path, otherwise, 0.

            Sample Input

            6 7
            14
            2 1
            6 6
            4 2
            2 5
            2 6
            2 7
            3 4
            6 1
            6 2
            2 3
            6 3
            6 4
            6 5
            6 7
            

            Sample Output

            7
            我第一次對自己的英持有懷疑態度。。。。一個半小時讀題,可能是在宿舍凈聽魔獸的聲音了。。。。。。
            靠,暈!
            maybe something wrong with me,
            I got ac with a time of 3.3s,but Others got ac with 700ms and 300k memory.
            Faint.....
            代碼巨丑,第一次用這么長時間,排了倒數幾名
            posted on 2009-01-08 20:44 KNIGHT 閱讀(292) 評論(1)  編輯 收藏 引用

            FeedBack:
            # re: The Troublesome Frog
            2009-01-08 22:32 | Knight
            我暈,一個晚上居然沒調出來。。。。。
            讀題還少了條件。。。。。
            現在可好了還是超時的東西。。。。  回復  更多評論
              
            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久无码人妻一区二区三区| 精品一区二区久久| 综合久久精品色| 久久青青色综合| 久久亚洲中文字幕精品有坂深雪 | 亚洲精品美女久久久久99| 波多野结衣AV无码久久一区| 亚洲人成伊人成综合网久久久| 久久国产高潮流白浆免费观看| 国产—久久香蕉国产线看观看| 一级a性色生活片久久无少妇一级婬片免费放 | 波多野结衣AV无码久久一区| 久久精品成人免费网站| 亚洲国产精品无码久久青草| 精品久久久久久中文字幕人妻最新| 精品多毛少妇人妻AV免费久久 | 99蜜桃臀久久久欧美精品网站| 国产精品久久国产精麻豆99网站| 亚洲欧美日韩精品久久亚洲区| 国产V综合V亚洲欧美久久| 中文字幕精品无码久久久久久3D日动漫| 国产精品久久久久影视不卡| 欧美精品国产综合久久| 秋霞久久国产精品电影院| 伊人久久大香线焦AV综合影院| 久久伊人五月天论坛| 久久香蕉国产线看观看99 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久伊人精品一区二区三区| 精品久久久久久无码国产| 91精品国产综合久久精品| 亚洲精品无码成人片久久| 亚洲国产成人乱码精品女人久久久不卡 | 国内精品久久久久影院网站| 久久人人爽人人爽人人AV东京热| 亚洲性久久久影院| 久久激情亚洲精品无码?V| 99久久免费只有精品国产| 久久亚洲国产中v天仙www | 青青热久久综合网伊人| 狠狠色伊人久久精品综合网|