• <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

            For any school, it is hard to find a feasible accommodation plan with every student assigned to a suitable apartment while keeping everyone happy, let alone an optimal one. Recently the president of University ABC, Peterson, is facing a similar problem. While Peterson does not like the idea of delegating the task directly to the class advisors as so many other schools are doing, he still wants to design a creative plan such that no student is assigned to a room he/she dislikes, and the overall quality of the plan should be maximized. Nevertheless, Peterson does not know how this task could be accomplished, so he asks you to solve this so-called "interesting" problem for him.
            Suppose that there are N students and M rooms. Each student is asked to rate some rooms (not necessarily all M rooms) by stating how he/she likes the room. The rating can be represented as an integer, positive value meaning that the student consider the room to be of good quality, zero indicating neutral, or negative implying that the student does not like living in the room. Note that you can never assign a student to a room which he/she has not rated, as the absence of rating indicates that the student cannot live in the room for other reasons.
            With limited information available, you've decided to simply find an assignment such that every student is assigned to a room he/she has rated, no two students are assigned to the same room, and the sum of rating is maximized while satisfying Peterson's requirement. The question is … what exactly is the answer?

            Input

            There are multiple test cases in the input file. Each test case begins with three integers, N, M, and E (1 <= N <= 500, 0 <= M <= 500, 0 <= E <= min(N * M, 50000)), followed by E lines, each line containing three numbers, Si, Ri, Vi, (0 <= Si < N, 0 <= Ri < M, |Vi| <= 10000), describing the rating Vi given by student Si for room Ri. It is guaranteed that each student will rate each room at most once.
            Each case is followed by one blank line. Input ends with End-of-File.

            Output

            For each test case, please output one integer, the requested value, on a single line, or -1 if no solution could be found. Use the format as indicated in the sample output.

            Sample Input

            3 5 5
            0 1 5
            0 2 7
            1 1 6
            1 2 3
            2 4 5

            1 1 1
            0 0 0

            1 1 0

            Sample Output

            Case 1: 18
            Case 2: 0
            Case 3: -1
            人品差沒得說,剛才寫了那么多居然沒有提交成功,第二次鄙視自己居然少寫判斷條件!!!
            本校的7016還一直TLE!!!
            本題就是普通的KM,外加判斷是否能構成完美匹配!!!
            ------------------------------------------------------------------------------------------------------------------
            本校也AC了,自己寫了個鄰接表!!!

            posted on 2009-03-24 21:03 KNIGHT 閱讀(204) 評論(0)  編輯 收藏 引用
            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品久久久久无码av| 94久久国产乱子伦精品免费 | 国产∨亚洲V天堂无码久久久| 色狠狠久久AV五月综合| 精品精品国产自在久久高清| 国产亚州精品女人久久久久久| 女同久久| 色综合久久综精品| 一本色道久久88综合日韩精品| 老色鬼久久亚洲AV综合| 久久人人超碰精品CAOPOREN| 日韩人妻无码精品久久免费一| 精品久久久久久国产牛牛app| 日韩人妻无码精品久久久不卡 | 婷婷久久香蕉五月综合加勒比| 久久香蕉国产线看观看99| 久久天天婷婷五月俺也去| 亚洲国产精品久久久久婷婷老年| 久久精品亚洲AV久久久无码| 93精91精品国产综合久久香蕉| 蜜臀久久99精品久久久久久小说| 日本国产精品久久| 国产精品成人99久久久久91gav| 欧美一区二区三区久久综| 模特私拍国产精品久久| 久久久99精品成人片中文字幕| 久久精品无码午夜福利理论片| 亚洲午夜精品久久久久久app| 国产精品成人精品久久久| 青青国产成人久久91网| 久久精品男人影院| 69国产成人综合久久精品| 人妻久久久一区二区三区| 婷婷综合久久中文字幕蜜桃三电影| 久久久国产99久久国产一| 久久天天躁狠狠躁夜夜不卡| 久久国产精品免费一区二区三区| 国产精品综合久久第一页| 久久久99精品一区二区| 亚洲AV伊人久久青青草原| 欧美精品乱码99久久蜜桃|