• <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
            人品差沒(méi)得說(shuō),剛才寫(xiě)了那么多居然沒(méi)有提交成功,第二次鄙視自己居然少寫(xiě)判斷條件!!!
            本校的7016還一直TLE!!!
            本題就是普通的KM,外加判斷是否能構(gòu)成完美匹配!!!
            ------------------------------------------------------------------------------------------------------------------
            本校也AC了,自己寫(xiě)了個(gè)鄰接表!!!

            posted on 2009-03-24 21:03 KNIGHT 閱讀(208) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            <2009年3月>
            22232425262728
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久99国产精品99久久| 国产成人久久精品二区三区| 精品久久久久久99人妻| 久久国产视频网| 久久久www免费人成精品| 国产精品无码久久综合| 久久精品人妻一区二区三区| 伊人久久成人成综合网222| 成人久久精品一区二区三区| 99久久精品免费看国产一区二区三区 | 中文国产成人精品久久不卡| 国产一区二区精品久久| 久久国产精品免费一区| 亚洲国产欧美国产综合久久| 国产福利电影一区二区三区,免费久久久久久久精 | 中文精品久久久久人妻| 国产精品九九九久久九九| 亚洲综合久久夜AV | 色综合久久最新中文字幕| 亚洲va中文字幕无码久久| 久久人妻少妇嫩草AV蜜桃| 久久91精品国产91久久户| 久久精品卫校国产小美女| 久久影院午夜理论片无码| 国产免费久久精品丫丫| 丁香狠狠色婷婷久久综合| 无码国内精品久久人妻| 囯产极品美女高潮无套久久久| 精品久久久久久无码人妻热| 99国产精品久久| 99久久国语露脸精品国产| 午夜天堂精品久久久久| 亚洲国产精品成人久久| 中文字幕无码免费久久| 久久亚洲日韩看片无码| 国产69精品久久久久观看软件| 久久精品成人欧美大片| 伊人久久大香线蕉综合热线| 色综合久久88色综合天天 | 伊人热热久久原色播放www | 国产精品久久久久AV福利动漫|