<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 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    PKU1042 – Gone Fishing

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

    我的做法是枚舉最遠到達的湖,減去相應的時間后貪心。

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

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

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

    另外我有這次比賽的測試數據和標程,需要的朋友留言即可。


     

    #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  回復  更多評論   

    2007-11-20 23:00 by 風木草
    lrx_919@yahoo.com.cn
    發一份測試數據給我,謝謝!

    # re: PKU1042 – Gone Fishing  回復  更多評論   

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

    # re: PKU1042 – Gone Fishing  回復  更多評論   

    2008-07-16 23:19 by kevin***
    我只要測試數據啊,請發一份給我,謝謝


    380061431@qq.com

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

    2008-09-27 20:18 by johnson
    發一份測試數據給我,謝謝!
    173125256@qq.com

    # re: PKU1042 – Gone Fishing  回復  更多評論   

    2009-04-06 19:08 by Blade
    要一份測試數據,謝謝
    lanefeng1989@163.com
    主站蜘蛛池模板: 福利免费观看午夜体检区| 成人嫩草影院免费观看| 日本免费人成视频在线观看| 亚洲精品无码av天堂| 亚洲精品欧美综合四区| 精品剧情v国产在免费线观看| 色拍自拍亚洲综合图区| 无码中文字幕av免费放dvd| 亚洲成AV人片一区二区密柚| 国内精品免费视频精选在线观看| 久久亚洲2019中文字幕| a级毛片免费高清毛片视频| 亚洲国产成人片在线观看| 日韩插啊免费视频在线观看 | 国内精品99亚洲免费高清| 一本一道dvd在线观看免费视频| 亚洲午夜精品一级在线播放放| 中国极品美軳免费观看| 亚洲国产精品第一区二区| 无码精品A∨在线观看免费| 久久久久亚洲国产| 免费观看国产小粉嫩喷水| 久久嫩草影院免费看夜色| 亚洲综合婷婷久久| 午夜男人一级毛片免费| 一级做α爱过程免费视频| 亚洲AV本道一区二区三区四区| 国产免费看JIZZ视频| 污视频网站免费在线观看| 久久精品国产精品亚洲艾| 99在线视频免费观看视频| 一级一黄在线观看视频免费| 无码专区—VA亚洲V天堂| 黄网址在线永久免费观看 | 亚洲美女中文字幕| 国产美女无遮挡免费网站| 国产午夜精品久久久久免费视| 伊人久久五月丁香综合中文亚洲| 亚洲Av无码乱码在线znlu| 91香蕉国产线在线观看免费| 亚洲国产精品成人午夜在线观看|