<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 403, comments - 310, trackbacks - 0, articles - 7
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    PKU1042 – Gone Fishing

    Posted on 2007-10-17 17:25 ZelluX 閱讀(970) 評論(5)  編輯  收藏 所屬分類: Algorithm

    我的做法是枚舉最遠(yuǎn)到達(dá)的湖,減去相應(yīng)的時間后貪心。

    貪心時需要建立一個堆,用了STL中的priority_queue,然后就不知道如何設(shè)置less<>方法了。。。
    最后是通過自定義一個類node解決的

    一開始寫的operator<方法邏輯上有問題,VS 2005跑了一會兒就冒出個 Debug assert error,這個挺贊的

    導(dǎo)致我WA的幾個數(shù)據(jù):
    1) 收益為0的幾組數(shù)據(jù)。由于一開始設(shè)置的max值為0,因此當(dāng)正解也是0時并沒有記錄下當(dāng)前的最優(yōu)解。max初始為負(fù)值即可。
    2) 同樣是0導(dǎo)致的問題。0收益的釣魚點也可能出現(xiàn)在堆中,此時應(yīng)該放棄這個點,把時間保留給序數(shù)大的釣魚點。

    另外我有這次比賽的測試數(shù)據(jù)和標(biāo)程,需要的朋友留言即可。


     

    #include <iostream>
    #include 
    <fstream>
    #include 
    <vector>
    #include 
    <queue>

    using namespace std;

    class node {
    public
        
    int first, second;

        node(
    int x, int y)
        
    {
            first 
    = x;
            second 
    = y;
        }


        
    bool operator< (const node &rhs) const
        
    {
            
    if (second < rhs.second) 
                
    return true;
            
    else if (second > rhs.second)
                
    return false;
            
    else return (first > rhs.first);
        }

    }
    ;


    int main()
    {
        
    int n, h;
        
    int d[26], t[26], f[26];
        priority_queue
    <node, vector<node>, less<vector<node>::value_type> > heap;
        vector
    <int> best(26);
        cin 
    >> n;
        
    while (true{
            
    if (n == 0break;
            cin 
    >> h;
            
    for (int i = 1; i <= n; i++)
                cin 
    >> f[i];

            
    for (int i = 1; i <= n; i++)
                cin 
    >> d[i];

            t[
    0= 0;
            
    for (int i = 1; i < n; i++)
                cin 
    >> t[i];

            best.clear();
            
    int max = -1;
            
    // i indicates the last lake
            for (int i = 1; i <= n; i++{
                vector
    <int> tempBest(26);
                
    int valueGet = 0;
                
                
    int timeLeft = h * 12;
                
    for (int j = 1; j <= i; j++)
                    timeLeft 
    -=    t[j - 1];

                
    if (timeLeft <= 0break;
                
    while (!heap.empty())
                    heap.pop();

                
    for (int j = 1; j <= i; j++)
                    heap.push(node(j, f[j]));

                
    while ((!heap.empty()) && (timeLeft > 0)) {
                    
    int next = heap.top().first;
                    
    if (heap.top().second > 0{
                        timeLeft
    --;
                        tempBest[next]
    ++;
                        valueGet 
    += heap.top().second;
                    }

                    
    int valueLeft = heap.top().second - d[next];
                    heap.pop();
                    
    if (valueLeft > 0)
                        heap.push(node(next, valueLeft));
                }

                
    if (valueGet > max) {
                    max 
    = valueGet;
                    best 
    = tempBest;
                    
    if (timeLeft > 0)
                        best[
    1+= timeLeft;
                }

            }

            printf(
    "%d", best[1* 5);
            
    for (int i = 2; i <= n; i++)
                printf(
    ", %d", best[i] * 5);
            printf(
    "\nNumber of fish expected: %d\n", max);
            cin 
    >> n;
            
    if (n != 0) cout << endl;
        }

        
    return 0;
    }


    評論

    # re: PKU1042 – Gone Fishing  回復(fù)  更多評論   

    2007-11-20 23:00 by 風(fēng)木草
    lrx_919@yahoo.com.cn
    發(fā)一份測試數(shù)據(jù)給我,謝謝!

    # re: PKU1042 – Gone Fishing  回復(fù)  更多評論   

    2007-11-23 20:40 by ZelluX
    這里有
    http://icpc.baylor.edu/past/icpc2000/regionals/ECNA99/Report.html

    # re: PKU1042 – Gone Fishing  回復(fù)  更多評論   

    2008-07-16 23:19 by kevin***
    我只要測試數(shù)據(jù)啊,請發(fā)一份給我,謝謝


    380061431@qq.com

    # re: PKU1042 – Gone Fishing[未登錄]  回復(fù)  更多評論   

    2008-09-27 20:18 by johnson
    發(fā)一份測試數(shù)據(jù)給我,謝謝!
    173125256@qq.com

    # re: PKU1042 – Gone Fishing  回復(fù)  更多評論   

    2009-04-06 19:08 by Blade
    要一份測試數(shù)據(jù),謝謝
    lanefeng1989@163.com
    主站蜘蛛池模板: 亚洲国产乱码最新视频| 色屁屁在线观看视频免费| caoporn国产精品免费| 国产精品国产免费无码专区不卡| 亚洲精品国产成人片| 黄页网站在线观看免费| 精品久久久久久久久免费影院| 国产免费一区二区三区| 亚洲精品福利视频| 亚洲五月综合网色九月色| 100部毛片免费全部播放完整| 51精品视频免费国产专区| 老司机亚洲精品影院| 84pao强力永久免费高清| 国产一级淫片免费播放| 亚洲经典在线中文字幕| 免费无码中文字幕A级毛片| 亚洲av永久无码精品漫画| 精品久久久久久亚洲综合网| 性色av免费观看| 性生大片视频免费观看一级| 成人超污免费网站在线看| 亚洲av无码成人精品国产| 亚洲国产黄在线观看| 国产精品亚洲综合久久| 国产精品公开免费视频| 国产精品永久免费视频| 亚洲丁香色婷婷综合欲色啪| 黄页网站免费观看| 美景之屋4在线未删减免费| 亚洲深深色噜噜狠狠爱网站| 日韩精品视频在线观看免费| 在线播放免费播放av片| 农村寡妇一级毛片免费看视频| 免费人成在线观看69式小视频| 国产a视频精品免费观看| 亚洲粉嫩美白在线| 亚洲欧洲中文日韩av乱码| 99精品在线免费观看| 色欲aⅴ亚洲情无码AV| 久久亚洲精品视频|