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

poj1073

Find them, Catch them

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 21467 Accepted: 6371

Description

The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify which gang a criminal belongs to. The present question is, given two criminals; do they belong to a same clan? You must give your judgment based on incomplete information. (Since the gangsters are always acting secretly.)

Assume N (N <= 10^5) criminals are currently in Tadu City, numbered from 1 to N. And of course, at least one of them belongs to Gang Dragon, and the same for Gang Snake. You will be given M (M <= 10^5) messages in sequence, which are in the following two kinds:

1. D [a] [b]
where [a] and [b] are the numbers of two criminals, and they belong to different gangs.

2. A [a] [b]
where [a] and [b] are the numbers of two criminals. This requires you to decide whether a and b belong to a same gang.

Input

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases. Then T cases follow. Each test case begins with a line with two integers N and M, followed by M lines each containing one message as described above.

Output

For each message "A [a] [b]" in each case, your program should give the judgment based on the information got before. The answers might be one of "In the same gang.", "In different gangs." and "Not sure yet."

Sample Input

1
5 5
A 1 2
D 1 2
A 1 2
D 2 4
A 1 4

Sample Output

Not sure yet.
In different gangs.
In the same gang.

Source

POJ Monthly--2004.07.18

囧,知道是并查集
也知道是根據路徑長度判斷是不是一個集合
但是 剛開始發現不能路徑壓縮,然后就裸的了,就tle了

然后………
寫了一串不知道是什么東西的東西,然后就過了
#include <cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
#include 
<ctime>
#include 
<cassert>
#include 
<iostream>
#include 
<sstream>
#include 
<fstream>
#include 
<map>
#include 
<set>
#include 
<vector>
#include 
<queue>
#include 
<algorithm>
#include 
<iomanip>
#define maxn 100005
using namespace std;
int father[maxn];
int mark[maxn];
int n,m;
int find(int x)
{
    
if(father[x]==x) return x;
    
else
    
{
       
int  pa=father[x];
        father[x]
=find(father[x]);
        mark[x]
=!(mark[x]^mark[pa]);
        
return father[x];
    }

}

void unit(int x,int y)
{
    
int r1,r2;
    r1
=find(x);
    r2
=find(y);
    father[r1]
=r2;
    mark[r1]
=!((!(mark[x]^0))^mark[y]);
}

void cas_init()
{
    
for(int i=1; i<=maxn; i++) father[i]=i,mark[i]=1;
}

int main()
{
    
int x,y,t,tmp1,tmp2,len1,len2;
    
char str[5];
    scanf(
"%d",&t);
    
while(t--)
    
{
        cas_init();
        scanf(
"%d%d",&n,&m);
        
for(int i=1; i<=m; i++)
        
{
            scanf(
"%s%d%d",str,&x,&y);
            
if(str[0]=='A')
            
{
                tmp1
=find(x);
                tmp2
=find(y);
                
if(tmp1==tmp2)
                
{
                    
if(mark[x]==mark[y])
                        printf(
"In the same gang.\n");
                    
else printf("In different gangs.\n");
                }

                
else printf("Not sure yet.\n");
            }

            
else if(str[0]=='D')
            
{
                unit(x,y);
            }

        }

    }

    
return 0;
}




posted on 2012-07-24 18:46 jh818012 閱讀(288) 評論(0)  編輯 收藏 引用


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


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導航

統計

常用鏈接

留言簿

文章檔案(85)

搜索

最新評論

  • 1.?re: poj1426
  • 我嚓,,輝哥,,居然搜到你的題解了
  • --season
  • 2.?re: poj3083
  • @王私江
    (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
  • --游客
  • 3.?re: poj3414[未登錄]
  • @王私江
    0ms
  • --jh818012
  • 4.?re: poj3414
  • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
  • --王私江
  • 5.?re: poj1426
  • 評論內容較長,點擊標題查看
  • --王私江
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲影视九九影院在线观看| 美女日韩欧美| 欧美午夜精品一区| 午夜精品福利在线| 亚洲综合色丁香婷婷六月图片| 国产又爽又黄的激情精品视频| 模特精品裸拍一区| 国产精品a级| 美日韩精品免费| 欧美日韩国产一区二区| 午夜精品久久久久99热蜜桃导演| 久久国产精品电影| 一区二区三区日韩欧美| 欧美一区1区三区3区公司| 亚洲日产国产精品| 夜夜嗨av一区二区三区| 午夜在线电影亚洲一区| 麻豆91精品91久久久的内涵| 亚洲自拍偷拍网址| 女女同性精品视频| 欧美成人性网| 欧美日韩裸体免费视频| 久久久久久高潮国产精品视| 欧美美女日韩| 麻豆9191精品国产| 国产精品国色综合久久| 亚洲第一久久影院| 欧美午夜欧美| 亚洲大胆美女视频| 国产午夜久久久久| 亚洲网站在线| 在线视频你懂得一区二区三区| 久久久免费观看视频| 欧美一区二区大片| 欧美色欧美亚洲高清在线视频| 麻豆av一区二区三区| 国产欧美一区二区三区视频| 中文在线一区| 亚洲小视频在线| 欧美精品福利在线| 欧美黄网免费在线观看| 在线成人黄色| 久久久国产精彩视频美女艺术照福利| 亚洲欧美一区二区三区久久| 欧美日韩一区二区三区视频| 亚洲经典自拍| 日韩午夜免费视频| 欧美成人网在线| 欧美黄在线观看| 亚洲激情第一页| 久久综合色播五月| 欧美福利小视频| 亚洲黄色一区| 欧美黄色日本| 亚洲精品久久久久中文字幕欢迎你 | 久久精品国产亚洲5555| 久久成人18免费观看| 国产精品一区在线观看| 国产精品99久久久久久久久久久久| 在线一区二区三区四区五区| 欧美日韩国产一区二区| 亚洲视频国产视频| 欧美资源在线观看| 一区免费观看视频| 免费在线欧美视频| 亚洲精品视频二区| 亚洲欧美日韩精品综合在线观看| 国产精品久久久久毛片软件| 亚洲欧美日韩一区二区三区在线| 久久精品国亚洲| 影音先锋中文字幕一区二区| 葵司免费一区二区三区四区五区| 亚洲第一精品夜夜躁人人躁| 国产精品99久久99久久久二8 | 久久久免费av| 久久精品国产亚洲aⅴ| 国外成人免费视频| 免费欧美视频| 亚洲精品久久久蜜桃 | 毛片基地黄久久久久久天堂| 亚洲国产精品传媒在线观看| 亚洲婷婷综合色高清在线| 国产精品亚洲综合天堂夜夜| 久久精品在线免费观看| 亚洲国产高清一区| 亚洲欧美bt| 黑人巨大精品欧美一区二区小视频| 免费在线一区二区| 亚洲网友自拍| 亚洲高清在线| 亚欧美中日韩视频| 在线视频国内自拍亚洲视频| 欧美日韩一区二区三区在线观看免| 亚洲欧美激情一区| 欧美激情亚洲自拍| 欧美一区二区高清在线观看| 亚洲激情婷婷| 国产日韩精品一区二区三区在线 | 欧美亚洲一区二区三区| 亚洲高清在线观看| 国产精品呻吟| 欧美区日韩区| 久久人人爽国产| 亚洲一区精品在线| 亚洲高清久久网| 久久日韩粉嫩一区二区三区| 亚洲午夜av电影| 亚洲激情视频网站| 国产亚洲欧洲| 欧美视频在线观看视频极品| 麻豆精品精华液| 欧美一区二区三区免费视频| 一本久久综合| 亚洲激情网站| 欧美96在线丨欧| 久久久www成人免费无遮挡大片| 99视频精品免费观看| 极品中文字幕一区| 国产女人18毛片水18精品| 欧美日韩国产区一| 免费成人你懂的| 久久久欧美一区二区| 亚洲欧美在线播放| 宅男精品视频| 日韩视频一区二区三区| 亚洲高清三级视频| 欧美va天堂va视频va在线| 久久国产手机看片| 性色av一区二区三区| 亚洲在线一区二区三区| 一区二区电影免费在线观看| 亚洲三级视频| 亚洲精品一区二区三区福利| 亚洲国产第一页| 亚洲大黄网站| 亚洲高清视频的网址| 激情久久婷婷| 伊人久久婷婷色综合98网| 国内自拍亚洲| 在线欧美视频| 亚洲黄色一区二区三区| 亚洲激情在线视频| 亚洲精品久久久久久一区二区| 亚洲国产精品尤物yw在线观看| 伊人精品在线| 亚洲激情视频网| 99在线精品免费视频九九视| 中日韩在线视频| 国产精品免费网站在线观看| 性伦欧美刺激片在线观看| 亚洲欧美在线一区二区| 午夜视频一区| 久久精品人人做人人爽| 久久久精品性| 久久阴道视频| 欧美激情国产日韩| 欧美日韩国产精品一区| 欧美吻胸吃奶大尺度电影| 国产精品久久777777毛茸茸| 国产精品视频yy9299一区| 国产嫩草一区二区三区在线观看 | 欧美激情自拍| 亚洲日韩中文字幕在线播放| 艳妇臀荡乳欲伦亚洲一区| 亚洲无线观看| 久久精品成人一区二区三区蜜臀| 久久人人97超碰精品888 | 亚洲国产成人久久综合一区| 亚洲精品午夜| 午夜精品视频在线观看| 久久久国产精品一区二区中文 | 欧美在线一区二区| 麻豆精品视频在线观看视频| 亚洲日韩欧美视频一区| 午夜日韩福利| 欧美va亚洲va香蕉在线| 国产精品高潮呻吟久久av无限 | 在线视频亚洲欧美| 久久国产手机看片| 欧美成人黄色小视频| 国产精品久久久久久久app | 性亚洲最疯狂xxxx高清| 麻豆成人在线播放| 国产精品裸体一区二区三区| 亚洲第一成人在线| 亚洲欧美成人精品| 亚洲国产精品t66y| 亚洲人成绝费网站色www| 欧美日韩三区| 国产一区二区视频在线观看| 亚洲免费高清视频| 久久国产一区二区三区| 亚洲欧洲午夜| 久久九九国产| 国产精品久久国产愉拍 | 亚洲卡通欧美制服中文| 欧美呦呦网站| 国产精品第一页第二页第三页| 亚洲国产高清高潮精品美女| 欧美亚洲三级|