青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

O(1) 的小樂

Job Hunting

公告

記錄我的生活和工作。。。
<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

統計

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

留言簿(10)

隨筆分類(70)

隨筆檔案(182)

文章檔案(1)

如影隨形

搜索

  •  

最新隨筆

最新評論

閱讀排行榜

評論排行榜

SRM 481

Div2

1 比較簡單的一道題目,理清楚邏輯關系。。

2 trick的一道題目,真是惡心人啊。。。從下面的一張圖中來看出種種的關系。。比賽的時候,糾結了。。所以沒搞出來。。

In the graphic, c + y will be equal to x (The total number of people that told you the correct answer) and a+b will be equal to n-x (The total number of people that told you the wrong answer). Since we know the number of elements in LIARS (liarCount) and the number of people in the intersection is assumed to be y we can conclude that a=lieCount-y. Similarly, b = liarCount-y. Since all the other literals are known, c = n - a - b - y. Knowing a, b, c and y we can verify: If (a+b) is equal to (n-x) and (c+y = x) then the scenario is possible. There is an implicit condition, an important one that was missed by many during the match, we do not want y to be so small, that the sum a+b-y is larger than n, this case can be detected by making sure that c is positive. Also note that since the numbers in the input can only be as large as 1000000, we can simply iterate through all the possible values of y until one for which the previous conditions hold.
We can then code a solution:

// Is the following scenario possible?:
//
// n people.
// x people told the truth.
// lieCount people were lied to.
// liarCount people lied intentionally
//
boolean check(int n, int x, int lieCount, int liarCount) {
    // Iterate through all the possible values of the intersection y:
    for (int y = 0; y <= lieCount && y <= liarCount; y++) {
        int a = lieCount - y;
        int b = liarCount - y;
        int c = n - a - b - y;

        // Do all the required conditions hold?
        if ( a+b==n-x && c+y==x && c>=0 ) {
            return true;
        }
    }
    return false;
}
//

public String theTruth(int n, int eggCount, int lieCount, int liarCount) {
    // Call the sub-routine, first assuming that the egg is the correct answer
    boolean egg =     check(n,eggCount, lieCount, liarCount );
    // Then assuming that the chicken is the correct answer:
    boolean chicken = check(n,n-eggCount, lieCount, liarCount );
    if(egg&&chicken) {
        return "Ambiguous";
    } else if (egg) {
        return "The egg";
    } else if (chicken) {
        return "The chicken";
    } else {
        return "The oracle is a lie";
    }
}
 

其中的邏輯關系還是很顯然的。。要淡定!。。。

QQ截圖未命名

看看某個房間里的情況。。唉,這告訴我們無論什么時候都不要放棄努力!

仔細和認真,有一個端正的態度是做好一切事情的法寶!

3 這個第三題應當和第二題換一下啊。。非常簡單。。

  因為一個人可能會有幾個job,但是一個job只能對應于一個人。。這就使問題變得非常簡單了。。很easy的會想到每個人的job duration和來做排序。。如果job duration 和相同,就以第一個首元素做排序標準。。

map <string,int> mp;
struct str{
       long long tot;
       int num;
       int next[55];
};
str st[55];
bool operator <(str a, str b)
{
     if (a.tot != b.tot)
        return a.tot < b.tot;
     return a.next[0] < b.next[0];
}
class BatchSystem
{
        public:
        vector <int> schedule(vector <int> duration, vector <string> user)
        {
               int n = duration.size();
               int i,j,t;
               int ct = 0;
               memset(st,0,sizeof(st));
               mp.clear();
               for (i = 0;i < n;i++)
               {
                   if (mp.find(user[i]) == mp.end())
                      mp[user[i]] = ct++;
                   t = mp[user[i]];
                   st[t].tot += duration[i];
                   st[t].next[st[t].num++] = i;
               }
               sort(st,st + ct);
               vector <int> ans;
               ans.clear();
               for (i = 0;i < ct;i++)
               {
                   for (j = 0;j < st[i].num;j++)
                       ans.push_back(st[i].next[j]);
               }
               return ans;
        }
};

剛開始的時候,以為這個題目中,一個job可以對應于幾個人的情況。。實在是不應該啊。。

 

 

 

===========================================================================================

不是很華麗的分割線。。。

===========================================================================================

DIV1

1 DIV2 500的題目,照例的惡心。。。

2 基于DIV900的那個理論,然后這次是求期望等待時間,需要分階段來討論。首先是在此人之前的人,其次是具有相同優先級的人,再次是這個人的不同工作之間。。總之,也是一個比較簡單的題目。

vector <double> expectedFinishTimes(vector <int> duration, vector <string> user)
{
    int n = duration.size();
    // Find users and their total durations:
    map<string, long long> userDuration;
    for (int i=0; i<n; i++) {
        userDuration[user[i]]+=duration[i];
    }
    vector<double> res(n);
    for (int i=0; i<n; i++) {
        int eqn = 0;
        double before = 0;
        // For each pair user, total duration:
        //   * count the number of users with the same
        //     total duration (eqn).
        //   * Accumulate the total duration from users
        //     with smaller total duration (before).
        for ( map<string,long long>::iterator it = userDuration.begin();
              it!=userDuration.end(); it++) {

            if (it->second < userDuration[user[i]] ) {
                before += it->second;
            } else if ( it->second == userDuration[user[i]] ) {
                eqn ++;
            }
        }
        // The time this process will have to wait is:
        //  before :
        //      The waiting time caused by users with lower total durations.
        // + (eqn-1) * userDuration[user[i]] / 2.0 :
        //      The expected waiting time caused by users with the same total duration.
        //
        // + (userDuration[user[i]]-duration[i]) / 2.0 :
        //      The expected waiting time caused by jobs from the same user.
        //
        // + duration[i]:
        //      The job's duration
        res[i] = before
                 + (eqn-1) * userDuration[user[i]] / 2.0
                 + (userDuration[user[i]]-duration[i]) / 2.0
                 + duration[i];
    }
    return res;
}
 
3 忘了什么意思了。。有時間貼出來。
Reference : 參考了SRM 481的解題報告和 best solution。。。代碼都是大大們寫的。。。學習!
 

posted on 2010-09-12 17:41 Sosi 閱讀(291) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


統計系統
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产精品伊人日日| 国产精品国产三级国产专播品爱网 | 亚洲特级片在线| 亚洲精品一区二区三区婷婷月| 欧美成人嫩草网站| 亚洲免费精品| 亚洲视频在线视频| 国产午夜精品一区理论片飘花 | 国产精品美女久久久久久2018 | 亚洲国产一区二区三区在线播 | 亚洲福利视频在线| 久久嫩草精品久久久久| 久久久久免费视频| 亚洲精品小视频在线观看| 亚洲九九九在线观看| 国产精品三级视频| 久久久亚洲午夜电影| 欧美大尺度在线观看| 亚洲一区二区三区在线看| 亚洲欧美日韩另类| 亚洲一级黄色片| 久久精品亚洲国产奇米99| 欧美成人精品1314www| 午夜欧美精品久久久久久久| 免费在线国产精品| 久久欧美肥婆一二区| 蜜桃av噜噜一区| 亚洲一区二区伦理| 欧美成年人视频| 亚洲第一福利社区| 免费黄网站欧美| 在线成人中文字幕| 亚洲免费一级电影| 国产免费一区二区三区香蕉精| 欧美午夜在线观看| 亚洲人成在线播放| 亚洲男同1069视频| 亚洲欧美日韩一区二区在线| 欧美激情视频在线播放| 狼人天天伊人久久| 国产亚洲观看| 国产精品久久久久久久久久免费看 | 欧美亚洲一区二区三区| 亚洲免费高清| 一二三区精品福利视频| 99国内精品| 亚洲国产高清在线观看视频| 激情六月婷婷久久| 欧美高清在线视频| 99re6热在线精品视频播放速度| 久久gogo国模裸体人体| 一区二区三区日韩欧美精品| 亚洲黄色高清| 日韩小视频在线观看专区| 欧美韩日亚洲| 亚洲欧美资源在线| 免费在线观看精品| 91久久综合亚洲鲁鲁五月天| 国产一区二区欧美| 亚洲嫩草精品久久| 欧美日韩国产在线一区| 欧美日本在线看| 亚洲国产精彩中文乱码av在线播放| 国产欧美精品在线| 欧美中文字幕第一页| 欧美天堂在线观看| 中文网丁香综合网| 亚洲在线观看| 国产精品一区二区三区免费观看| 亚洲美女视频在线观看| 亚洲视频久久| 国产精品进线69影院| 亚洲午夜高清视频| 性高湖久久久久久久久| 国产欧美精品日韩区二区麻豆天美| 亚洲视频第一页| 欧美影视一区| 国产揄拍国内精品对白| 久久精品理论片| 免费不卡在线观看| 91久久精品视频| 欧美日韩一区二区在线观看| 中国成人在线视频| 久久精品最新地址| 亚洲电影天堂av| 欧美伦理91| 午夜视频在线观看一区| 久久字幕精品一区| 亚洲免费观看| 国产精品欧美一区喷水| 久久婷婷丁香| 亚洲免费成人av电影| 久久国产主播| 亚洲国产国产亚洲一二三| 欧美日韩不卡| 欧美一级黄色网| 欧美激情久久久久| 亚洲综合色丁香婷婷六月图片| 国产一区二区黄| 欧美精品一区二区三区视频| 亚洲一级在线观看| 欧美国产一区二区在线观看| 亚洲性感激情| 在线精品观看| 国产精品久久久久一区| 久久精品视频在线观看| 日韩图片一区| 免费看的黄色欧美网站| 亚洲一区二区三区免费观看| 国语自产偷拍精品视频偷| 欧美女激情福利| 久久精品欧美| 一本到高清视频免费精品| 老司机午夜精品视频| 亚洲一区国产| 亚洲日本一区二区三区| 国产色产综合产在线视频| 欧美美女喷水视频| 久久这里只有精品视频首页| 亚洲综合国产激情另类一区| 亚洲国产精品一区二区第一页 | 美女网站久久| 亚洲在线视频免费观看| 亚洲国产精品久久久久秋霞蜜臀| 国产精品毛片在线看| 欧美日韩亚洲天堂| 欧美高清自拍一区| 可以免费看不卡的av网站| 午夜欧美精品| 亚洲一区二区三区高清不卡| 亚洲国产精品免费| 欧美粗暴jizz性欧美20| 久久久精彩视频| 欧美伊人久久大香线蕉综合69| 亚洲一区二区三区精品在线| 亚洲精选久久| 日韩一级在线观看| 夜夜爽www精品| 亚洲免费观看在线观看| 亚洲日本免费电影| 亚洲欧洲一区二区三区久久| 亚洲国产高清在线| 亚洲国产精品黑人久久久| 好吊一区二区三区| 激情伊人五月天久久综合| 国模吧视频一区| 在线看片日韩| 亚洲国产欧美精品| 亚洲欧洲综合另类| 亚洲久久在线| 在线性视频日韩欧美| 亚洲一级黄色av| 性18欧美另类| 久久在线免费观看视频| 美女在线一区二区| 亚洲国产日本| 一区二区三区鲁丝不卡| 亚洲欧美日韩一区二区| 久久国产精彩视频| 久久综合狠狠| 欧美日韩视频在线观看一区二区三区| 欧美色图一区二区三区| 欧美午夜一区二区三区免费大片 | 欧美福利一区二区| 欧美激情综合在线| 欧美性一区二区| 国产最新精品精品你懂的| 亚洲福利免费| 日韩视频在线播放| 亚洲欧美日韩一区二区| 美日韩精品免费观看视频| 亚洲福利视频网站| 一区二区三区视频观看| 久久精品二区| 欧美日韩国产首页在线观看| 国产精品欧美精品| 亚洲国产高清视频| 亚洲女同同性videoxma| 欧美成在线观看| 亚洲视频免费看| 麻豆精品精华液| 国产精品美女久久久久av超清| 樱桃成人精品视频在线播放| 99这里只有久久精品视频| 欧美专区亚洲专区| 最新日韩在线视频| 性欧美大战久久久久久久久| 欧美高清视频一二三区| 国产视频久久网| 亚洲一区视频在线| 欧美xx69| 欧美中文字幕第一页| 欧美日韩国产小视频在线观看| 国内精品免费午夜毛片| 亚洲天堂成人| 亚洲精品日韩激情在线电影| 久久久久.com| 国产乱码精品1区2区3区| 亚洲精品社区| 免费欧美电影|