• <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>
            隨筆-65  評(píng)論-6  文章-0  trackbacks-0
             1 #include <cstdio>
             2 #include <cstdlib> //加這兩個(gè)頭文件比<iostream>省空間
             3 using namespace std;
             4 #define MAXSIZE    2005
             5 int oppo[MAXSIZE],par[MAXSIZE];
             6 int yes;
             7 char c;
             8 
             9 void makeSet(int n){
            10     int i;
            11     for(i=0;i<=n;i++)
            12         oppo[i]=-1,par[i]=i;
            13     yes=1;
            14 }
            15 int findSet(int x){
            16     if(x!=par[x])
            17         par[x]=findSet(par[x]);
            18     return par[x];
            19 }
            20 void merge(int x,int y){
            21     par[findSet(x)]=findSet(y);
            22 }
            23 inline void scan(int &x){
            24     while(c=getchar(),c<'0'||c>'9');x=c-'0';
            25     while(c=getchar(),c>='0'&&c<='9')x=x*10+c-'0';    
            26 }
            27 
            28 int main(){
            29     int t,no=1;
            30     //scanf("%d",&t);
            31     scan(t);//recommend this style of input,faster than scanf()
            32     while (t--){
            33         int n,m;//the number of bugs And the interactions
            34         scan(n);scan(m);
            35         int i,j;
            36         makeSet(n);
            37         for(i=0;i<m;i++){
            38             int a,b;
            39             scan(a);scan(b);
            40             if(yes){
            41                 if (oppo[a]==-1&&oppo[b]==-1){// a b both appear at first time
            42                     oppo[a]=b;oppo[b]=a;
            43                 }
            44                 else if (oppo[a]==-1){
            45                     oppo[a]=b;merge(a,oppo[b]);
            46                 }
            47                 else if (oppo[b]==-1){
            48                     oppo[b]=a;merge(b,oppo[a]);
            49                 }
            50                 else{
            51                     if (findSet(a)==findSet(b))
            52                         yes=0;
            53                     else{
            54                         merge(a,oppo[b]);
            55                         merge(b,oppo[a]);
            56                     }
            57                 }
            58             }
            59         }
            60         printf("Scenario #%d:\n",no++);
            61         printf(yes?"No suspicious bugs found!":"Suspicious bugs found!");
            62         printf("\n\n");
            63     }
            64     return 0;
            65 }
            posted on 2012-03-16 14:42 Leo.W 閱讀(493) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久久人妻一区精品| 久久777国产线看观看精品| 久久笫一福利免费导航 | 精品永久久福利一区二区| 久久久久99精品成人片欧美| 国产91色综合久久免费| 色婷婷久久久SWAG精品| 国产精品免费福利久久| 久久久久久国产a免费观看不卡| 久久精品人妻中文系列| 国产精品久久永久免费| 欧美日韩精品久久久久| 狠狠色丁香久久综合五月| 久久这里只有精品首页| 亚洲成色999久久网站| 狠狠综合久久综合88亚洲| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 久久狠狠高潮亚洲精品| 国产真实乱对白精彩久久| 久久人人爽人人爽人人片av高请| 久久夜色撩人精品国产小说| 久久狠狠高潮亚洲精品| 久久久久久亚洲Av无码精品专口 | 69久久夜色精品国产69| 一本一本久久a久久综合精品蜜桃 一本一道久久综合狠狠老 | 一本色道久久综合狠狠躁篇| 人妻精品久久久久中文字幕69| 99久久精品影院老鸭窝| 久久久久免费精品国产| 久久久久亚洲精品天堂久久久久久| 久久婷婷五月综合色高清| 免费精品久久天干天干| 欧美久久一区二区三区| 久久亚洲中文字幕精品一区| 国产精品狼人久久久久影院| 久久久久综合网久久| 精品久久久久久中文字幕| 国产欧美久久一区二区| 99热精品久久只有精品| 精品国产综合区久久久久久 | 久久99精品国产99久久|