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

O(1) 的小樂

Job Hunting

公告

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

統計

  • 隨筆 - 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 閱讀(280) 評論(0)  編輯 收藏 引用

統計系統
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲第一在线综合网站| 国产三级精品三级| 亚洲国产毛片完整版 | 国产精品久久久一区二区三区| 99热精品在线| 日韩一二三区视频| 国产精品久久午夜| 欧美一级二区| 久久国产主播| 亚洲精品美女久久7777777| 亚洲欧洲另类| 国产精品高清在线观看| 午夜伦欧美伦电影理论片| 亚洲欧美春色| 在线观看一区| 夜夜精品视频一区二区| 国产精品毛片| 欧美成人精品一区二区| 欧美日韩国产在线播放| 久久精品国产一区二区三| 免费在线欧美视频| 亚洲一区中文| 久久久夜精品| 一区二区三区精品国产| 欧美一二三视频| 日韩视频永久免费观看| 亚洲欧美日韩直播| 亚洲国产精品一区制服丝袜 | 亚洲午夜久久久| 欧美在线3区| 99综合电影在线视频| 午夜宅男久久久| 亚洲精品永久免费精品| 亚洲欧美激情四射在线日| 亚洲人被黑人高潮完整版| 亚洲天堂成人| 亚洲精品影视在线观看| 久久er精品视频| 亚洲视频综合在线| 老司机精品福利视频| 亚洲欧美日韩在线高清直播| 久久免费视频这里只有精品| 性欧美在线看片a免费观看| 免费在线一区二区| 久久久国产精品一区| 欧美视频四区| 亚洲国产精品综合| 一区二区在线看| 亚洲一区视频| 亚洲视频在线观看网站| 欧美mv日韩mv亚洲| 久久综合九色| 国产亚洲欧美日韩精品| 在线视频欧美一区| 99精品国产在热久久下载| 久久女同互慰一区二区三区| 欧美在线一二三四区| 欧美性感一类影片在线播放| 亚洲精品乱码久久久久久黑人| 在线观看欧美激情| 久久精品国产96久久久香蕉| 欧美一区二区在线观看| 国产精品久久久久久久久搜平片 | 在线视频一区观看| 欧美成人免费全部观看天天性色| 美日韩精品免费| 韩日成人在线| 久久久五月婷婷| 免费精品视频| 亚洲国产免费看| 女女同性女同一区二区三区91| 麻豆成人在线观看| 樱花yy私人影院亚洲| 久久影视精品| 亚洲国产小视频| 日韩天堂在线观看| 欧美日韩系列| 亚洲一区在线播放| 欧美一区二区三区在线播放| 国产拍揄自揄精品视频麻豆| 性欧美1819sex性高清| 久久免费高清| 亚洲精品字幕| 欧美日韩综合在线| 亚洲尤物在线视频观看| 久久亚洲精品欧美| 最新亚洲激情| 欧美日韩网址| 亚洲欧美日韩精品久久| 午夜精品免费在线| 在线综合+亚洲+欧美中文字幕| 一本色道久久99精品综合| 欧美日韩在线看| 亚洲欧美日韩中文播放| 蜜臀av国产精品久久久久| 亚洲黄色av| 欧美午夜片在线观看| 欧美与黑人午夜性猛交久久久| 欧美va亚洲va国产综合| 中文av字幕一区| 国产一区成人| 欧美精品少妇一区二区三区| 亚洲综合999| 欧美激情一二三区| 亚洲欧美精品在线| 在线成人欧美| 国产精品久久久免费| 久久精品首页| 日韩写真在线| 久久综合网hezyo| 亚洲小说欧美另类社区| 精品91在线| 国产精品www网站| 久久免费的精品国产v∧| 国产精品99久久99久久久二8| 男女激情久久| 欧美一级视频精品观看| 亚洲精品日韩精品| 国产在线麻豆精品观看| 欧美日韩一区二区三| 久久综合九色99| 午夜亚洲影视| 在线亚洲激情| 91久久久久久国产精品| 久久久精品日韩欧美| 欧美影院精品一区| 国产精品高潮呻吟久久av无限| 久久综合伊人77777麻豆| 亚洲已满18点击进入久久| 91久久一区二区| 欧美不卡视频| 久久伊人一区二区| 欧美一区二区三区喷汁尤物| 制服诱惑一区二区| 日韩视频在线观看免费| 国内一区二区三区| 国产日韩欧美电影在线观看| 国产精品福利网站| 欧美色道久久88综合亚洲精品| 欧美成年人网| 久久这里有精品视频| 久久精品91久久久久久再现| 午夜精品久久久久久久久久久| 亚洲午夜一区二区三区| 国产精品99久久久久久白浆小说 | 韩国成人福利片在线播放| 欧美人妖在线观看| 欧美精品乱码久久久久久按摩 | 亚洲精品视频一区二区三区| 亚洲福利免费| 亚洲国产经典视频| 亚洲第一偷拍| 亚洲人成亚洲人成在线观看| 欧美激情在线狂野欧美精品| 欧美韩国在线| 亚洲人被黑人高潮完整版| 欧美激情一区二区三区在线视频 | 在线视频免费在线观看一区二区| 亚洲美女av黄| 一区二区三区福利| 亚洲一区www| 久久av在线看| 久久久亚洲国产天美传媒修理工 | 9色porny自拍视频一区二区| 99国产精品久久久久久久久久| 在线亚洲国产精品网站| 亚洲欧美日韩国产综合在线| 久久精品成人一区二区三区蜜臀 | 999亚洲国产精| 亚洲在线播放| 久久久xxx| 亚洲电影激情视频网站| 9l视频自拍蝌蚪9l视频成人| 亚洲男人第一av网站| 玖玖综合伊人| 欧美视频一区| 激情综合网激情| 一本一本久久| 久久亚洲春色中文字幕| 亚洲人成在线观看网站高清| 亚洲一区二区三| 久久综合色影院| 国产精品成人一区二区三区夜夜夜 | 欧美成va人片在线观看| 日韩视频国产视频| 久久国产精品久久久久久久久久| 欧美成人精品在线播放| 国产欧美一区二区三区在线老狼 | 国产精品jizz在线观看美国 | 国内外成人在线| 夜夜嗨一区二区| 久久九九99| av成人免费观看| 欧美电影免费观看| 国产欧美婷婷中文| 这里只有精品电影| 麻豆久久婷婷| 亚洲男女毛片无遮挡| 欧美日韩激情小视频| 亚洲高清不卡在线|