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

            O(1) 的小樂

            Job Hunting

            公告

            記錄我的生活和工作。。。
            <2011年4月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            統計

            • 隨筆 - 182
            • 文章 - 1
            • 評論 - 41
            • 引用 - 0

            留言簿(10)

            隨筆分類(70)

            隨筆檔案(182)

            文章檔案(1)

            如影隨形

            搜索

            •  

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            TCO Round1

            1 比較簡單,不過不是那么容易想。
              給定初始字符串,然后兩個緩沖隊列,把初始字符串經過一部分操作變成目標字符串。
             
              由于具有兩個緩沖隊列,而且初始字符串中字符只有兩類,所以可以一次搞定!利用substr() 判斷一下就OK
             
            2  應該觀察到對最后的期望有貢獻的只是具有連續洼地的地方,所以只要枚舉出現連續洼地的期望就可以了,復雜度是O(n^2)的,然后下面的代碼就非常清楚了!主要是沒有注意這個關鍵點!
            class MuddyRoad{
              public:
              double getExpectedValue(vector <int> road){
                vector<double> prob;
                for(int i=0;i<road.size();i++)prob.push_back((double)road[i]/100);
                int n=prob.size();
                double ans=0;
                for(int i=1;i<=n-2;i++){
                  for(int j=i;j<=n-2;j++){
                    int c=(j-i+1)/2;
                    double p=1;
                    p*=(1-prob[i-1]);
                    p*=(1-prob[j+1]);
                    for(int k=i;k<=j;k++)p*=prob[k];
                    ans+=p*c;
                  }
                }
                return ans;
              }
            };

            當時比賽的時候,我在想DP的狀態轉移,貌似寫挫了,不太清楚O(n)的算法思路和我的是否相似。。
             
             
            3
            看來還是蠻簡單的,就是一個容斥原理啊,復雜度是O(nlogn)+O(n)* O(容斥)
            容斥其實是蠻難做的!看下面這個:
            The simplest approach would be to go over all 1,000,000,000,000 IP addresses individually, and for each one, check all the requests to see who offers the highest price, and then add that to the total.

            This works perfectly except it will obviously be too slow. So instead of looking at individual IP addresses, we should partition the set of all IP addresses, so that each part will be assigned to a single buyer. Then, we simply need to find the size and price for each part, and we can easily multiply and add them together.

            For example, if we have requests for "1.2.3.0", "1.2.3.1" and "1.2.3.*" then interesting parts would be {"1.2.3.0"}, {"1.2.3.1"}, and {"1.2.3.2","1.2.3.3",...,"1.2.3.999"}. All of these can be represented implicitly if we take a special value (like -1 in bmerry's code) to mean "all other, unused values".

            Since the interesting values for each component come from the N requests in the input, there are at most N4 parts to check (or (N+1)4 in bmerry's code). With an additional loop for each part this yields an O(N5) algorithm.

            posted on 2011-06-26 13:21 Sosi 閱讀(210) 評論(1)  編輯 收藏 引用

            評論

            # re: TCO Round1 2011-07-26 16:14 雙星休閑鞋

            看得還真是挺復雜的。
              回復  更多評論    
            統計系統
            久久精品中文无码资源站| 国产999精品久久久久久| 欧美粉嫩小泬久久久久久久 | 2021久久精品国产99国产精品| 日日狠狠久久偷偷色综合免费 | 亚洲AV成人无码久久精品老人| 色妞色综合久久夜夜| 精品一二三区久久aaa片| 狠狠色丁香婷婷久久综合五月| 天天做夜夜做久久做狠狠| 亚洲美日韩Av中文字幕无码久久久妻妇 | 久久综合狠狠综合久久综合88| 久久99国产精品久久99小说| 国产成人精品免费久久久久| 久久996热精品xxxx| 国产麻豆精品久久一二三| 亚洲国产天堂久久久久久| 久久精品国产福利国产秒| 久久久久亚洲Av无码专| 狠狠色丁香久久婷婷综合蜜芽五月| 国产精品美女久久久| 精品国产99久久久久久麻豆| 人妻精品久久久久中文字幕| 777久久精品一区二区三区无码| 久久久久女人精品毛片| 99久久国产宗和精品1上映| 四虎影视久久久免费观看| 久久久久国产视频电影| 精品久久久久中文字| 99久久精品免费看国产| 国产99久久九九精品无码| 国产一区二区精品久久凹凸| 久久香蕉国产线看观看乱码| 1000部精品久久久久久久久| 久久A级毛片免费观看| AV色综合久久天堂AV色综合在 | 国产精品成人精品久久久| 久久天堂电影网| 久久精品国产黑森林| 怡红院日本一道日本久久 | 久久一日本道色综合久久|