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

            公告

            記錄我的生活和工作。。。
            <2010年9月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            統(tǒng)計

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

            留言簿(10)

            隨筆分類(70)

            隨筆檔案(182)

            文章檔案(1)

            如影隨形

            搜索

            •  

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            TCO Round1

            1 比較簡單,不過不是那么容易想。
              給定初始字符串,然后兩個緩沖隊列,把初始字符串經(jīng)過一部分操作變成目標(biāo)字符串。
             
              由于具有兩個緩沖隊列,而且初始字符串中字符只有兩類,所以可以一次搞定!利用substr() 判斷一下就OK
             
            2  應(yīng)該觀察到對最后的期望有貢獻(xiàn)的只是具有連續(xù)洼地的地方,所以只要枚舉出現(xiàn)連續(xù)洼地的期望就可以了,復(fù)雜度是O(n^2)的,然后下面的代碼就非常清楚了!主要是沒有注意這個關(guān)鍵點!
            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;
              }
            };

            當(dāng)時比賽的時候,我在想DP的狀態(tài)轉(zhuǎn)移,貌似寫挫了,不太清楚O(n)的算法思路和我的是否相似。。
             
             
            3
            看來還是蠻簡單的,就是一個容斥原理啊,復(fù)雜度是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 閱讀(213) 評論(1)  編輯 收藏 引用

            評論

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

            看得還真是挺復(fù)雜的。
              回復(fù)  更多評論    
            統(tǒng)計系統(tǒng)
            久久免费观看视频| 久久国产欧美日韩精品| 久久亚洲精品无码VA大香大香| 久久免费视频一区| 浪潮AV色综合久久天堂| 97精品国产97久久久久久免费| 亚洲精品综合久久| 97热久久免费频精品99| 热久久国产欧美一区二区精品| 亚洲va久久久噜噜噜久久天堂| 精品久久久久久久中文字幕| 伊人久久无码中文字幕| 久久久久久久综合日本| 97久久国产亚洲精品超碰热| 久久久久久午夜精品| 国产精自产拍久久久久久蜜| 久久精品国产亚洲AV无码麻豆 | 国产99久久久久久免费看 | 亚洲成色WWW久久网站| 久久99精品久久久久久9蜜桃| 国产精品久久久久久久久免费| 精品久久久中文字幕人妻| 久久精品女人天堂AV麻| 香蕉久久夜色精品国产小说| 婷婷久久香蕉五月综合加勒比| 色老头网站久久网| 久久毛片一区二区| 国产精品中文久久久久久久| 久久这里只有精品视频99| 国产精品美女久久久久AV福利| 久久福利青草精品资源站免费| 久久久久亚洲精品无码蜜桃| 天天爽天天狠久久久综合麻豆| 久久中文字幕人妻丝袜| 国产aⅴ激情无码久久| 91麻豆国产精品91久久久| 亚洲伊人久久成综合人影院| 性做久久久久久久久老女人| 久久久久亚洲精品日久生情 | 91精品国产高清久久久久久91| 93精91精品国产综合久久香蕉|