锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久国产精品成人免费,国产精品99久久精品爆乳,国产精品成人99久久久久91gavhttp://www.shnenglu.com/luyulaile/category/11068.htmlI canzh-cnSun, 05 Jul 2009 17:04:43 GMTSun, 05 Jul 2009 17:04:43 GMT60poj 1611 the suspect 騫舵煡闆?/title><link>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html</link><dc:creator>luis</dc:creator><author>luis</author><pubDate>Fri, 03 Jul 2009 08:51:00 GMT</pubDate><guid>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html</guid><wfw:comment>http://www.shnenglu.com/luyulaile/comments/89172.html</wfw:comment><comments>http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/luyulaile/comments/commentRss/89172.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/luyulaile/services/trackbacks/89172.html</trackback:ping><description><![CDATA[<p class=pst>Description</p> <p class=pst>Description</p> <div id="4cwwcc8" class=ptx lang=en-US>Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others. <br>In the Not-Spreading-Your-Sickness University (NSYSU), there are many student groups. Students in the same group intercommunicate with each other frequently, and a student may join several groups. To prevent the possible transmissions of SARS, the NSYSU collects the member lists of all student groups, and makes the following rule in their standard operation procedure (SOP). <br>Once a member in a group is a suspect, all members in the group are suspects. <br>However, they find that it is not easy to identify all the suspects when a student is recognized as a suspect. Your job is to write a program which finds all the suspects.</div> <p class=pst>Input</p> <div id="cise4uo" class=ptx lang=en-US>The input file contains several cases. Each test case begins with two integers n and m in a line, where n is the number of students, and m is the number of groups. You may assume that 0 < n <= 30000 and 0 <= m <= 500. Every student is numbered by a unique integer between 0 and n−1, and initially student 0 is recognized as a suspect in all the cases. This line is followed by m member lists of the groups, one line per group. Each line begins with an integer k by itself representing the number of members in the group. Following the number of members, there are k integers representing the students in this group. All the integers in a line are separated by at least one space. <br>A case with n = 0 and m = 0 indicates the end of the input, and need not be processed.</div> <p class=pst>Output</p> <div id="a8q8kas" class=ptx lang=en-US>For each case, output the number of suspects in one line.</div> <p class=pst>Sample Input</p> <pre class=sio>100 4 2 1 2 5 10 13 11 12 14 2 0 1 2 99 2 200 2 1 5 5 1 2 3 4 5 1 0 0 0</pre> <p class=pst>Sample Output</p> <pre class=sio>4 1 1</pre> <p>鍚ず1錛屼竴瀹氭敞鎰忓垵濮嬪寲甯︽潵鐨勫獎鍝嶏紝1錛屾槸浠涔堝湴鏂瑰垵濮嬪寲錛?錛屽墠涓涓猚ase涓嶅簲褰撳涓嬩竴涓犳垚褰卞搷<br>        2錛屾湁灞傛鎬х殑闂涓瀹氳澶勭悊濂斤紝涓嶈<br>        3錛屼緥濡傞噸澶嶆暟鎹笉鑳介噸澶嶅垵濮嬪寲銆?br>                          cin>>t;<br>                           if(father[t]<0)//蹇呬笉鍙皯<br>                             father[t]=t;<br><br><br>#include<iostream><br>#include<cstdlib><br>using namespace std;<br>  int rank[30001];<br>  int father[30001];<br>  void UNION(int a,int b)<br>  {<br>  if(a==b)return;<br>  else<br>  {<br>   if(rank[a]<rank[b])<br>   {<br>    father[b]=father[a];<br>      }<br>   else<br>   {<br>    father[a]=father[b];<br>   } <br>  }<br>  <br>  }<br>  int Find(int t)<br>  {<br>  int tmp=t,x;<br>  while(father[tmp]!=tmp)<br>  {<br>   tmp=father[tmp];<br>  }<br>  <br>  while(t!=father[t])<br>  {<br>      x=t;<br>      t=father[x];<br>   father[x]=tmp;<br>     } </p> <p>     return t;<br>  }<br>  int main()<br>  {<br>  freopen("s.txt","r",stdin);<br>  freopen("key.txt","w",stdout);<br>  int i,j,nt,t1,t,result;<br>  while(cin>>i>>j,i||j)<br>  {<br>  result=0;<br>  memset(rank,1,sizeof(rank));<br>  memset(father,-1,sizeof(father));<br>  rank[0]=0;<br>  father[0]=0;<br> for(int k=0;k<j;k++)<br> {<br>  cin>>nt;<br>  cin>>t1;<br>  rank[t1]=t1;<br>  if(father[t1]<0)<br>    father[t1]=t1;<br>  for(int m=1;m<nt;m++)<br>  {<br>   cin>>t;<br>   rank[t]=t;<br>   if(father[t]<0)<br>    father[t]=t;<br>   UNION(Find(t1),Find(t));<br>  }<br> }<br> for(int l=0;l<i;l++)<br> {<br>  if(father[l]>=0)<br>  {<br>   if(!Find(l))<br>  result++;<br>     }<br> }<br> cout<<result<<endl;<br>  <br>  }</p> <p>  //system("PAUSE");<br>  return   0;<br>  }</p> <img src ="http://www.shnenglu.com/luyulaile/aggbug/89172.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/luyulaile/" target="_blank">luis</a> 2009-07-03 16:51 <a href="http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍝堝笇琛?poj 3320 Jessica's Reading Problemhttp://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.htmlluisluisWed, 01 Jul 2009 05:00:00 GMThttp://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.htmlhttp://www.shnenglu.com/luyulaile/comments/88982.htmlhttp://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.html#Feedback0http://www.shnenglu.com/luyulaile/comments/commentRss/88982.htmlhttp://www.shnenglu.com/luyulaile/services/trackbacks/88982.htmlpoj 3320 Jessica's Reading Problem http://acm.pku.edu.cn/JudgeOnline/problem?id=3320
榪欓亾棰樼洰鍙互鐢ㄥ搱甯岃〃娉曚篃鍙互鐢ㄤ簩鍒嗘煡鎵炬硶錛岀幇鍦ㄧ敤鍝堝笇錛屼簩鍒嗘煡鎵懼皢鍦ㄥ悗闈㈢殑鍗氬涓帹鍑恒?br>榪欓亾棰樼洰鐢ㄥ埌鐨勬槸鏁扮殑鍝堝笇錛屽浜庝笉闇瑕佸垹闄ょ殑瀛楀吀錛屽搱甯岃〃鏄竴縐嶇悊鎯崇殑瀹炵幇鏂瑰紡銆?br>1.鍝堝笇琛ㄧ殑鎻掑叆鍜屾煡鎵劇畻娉?br>(1)璁$畻鍑芥暟鍊糷(k)
(2)浠庢Ыh(k)寮濮嬶紝浣跨敤鍐茬獊瑙e喅絳栫暐瀹氫綅鍖呭惈鍏抽敭鐮乲鐨勭邯褰?br>(3)濡傛灉闇瑕佹彃鍏ワ紝鍐嶆Ы鍐呮彃鍏ュ嵆鍙?br>涓ょ鎿嶄綔鐨勫鏉傚害鍦ㄥ拷鐣ュ啿紿佹椂鏄疧(1)
2.鍝堝笇鍑芥暟鐨勯夊彇
鏈浣跨敤鏈綆鍗曠殑鐩存帴鍙栦綑娉曪紝闄ゆ暟涓篜RIME錛屾渶濂芥槸璐ㄦ暟錛屽彲鍑忓皬鍐茬獊銆?br>3.鍐茬獊瑙e喅鏂規(guī)硶
寮鏁e垪娉曪紙榪欎篃鏄ぇ澶氭暟鎯呭喌涓嬩嬌鐢ㄧ殑錛?br>寮鏁e垪娉曚篃鍙媺閾炬硶錛岄氫織鍦拌灝辨槸“鏃㈢劧鍏冪礌a鍜宐閮借鏀懼湪閲岄潰錛屽彧濂芥尋涓鎸や簡”銆傚嵆鍦ㄦ瘡涓Ы閲屽瓨鏀炬墍鏈夎鏀懼湪閲岄潰鐨勫厓绱犮傞偅涔堟庝箞鎶婂緢澶氱殑鍏冪礌鏀懼湪妲介噷鍛紵鍙湪妲介噷鏀句竴涓摼琛ㄨ〃澶村氨琛屼簡錛岃閾捐〃涓寘鍚墍鏈夎鏀懼湪妲介噷鐨勫厓绱犮備絾鍦ㄥ疄闄呬腑騫朵笉鏄繖鏍峰仛鐨勶紝鑰屾槸鑷繁緇存姢涓涓ぇ鏁扮粍錛岀粰閾捐〃鍏冪礌鍒嗛厤鏁扮粍涓嬫爣錛岃繖鏍鋒棦鏂逛究鍙堣妭鐪佹椂闂村拰絀洪棿銆傞偅涔堥摼琛ㄤ腑鐨勫厓绱犵殑鎺掑垪欏哄簭鎬庢牱鍛紵濡傛灉鎸夌収鏌ユ壘鎴愬姛鏃剁殑鏁堢巼錛屾樉鐒跺彲浠ユ寜鐓ц闂殑棰戠巼錛涜屽鏋滄寜鐓ф煡鎵懼け璐ョ殑鏁堢巼錛屽垯鍙互鎸夌収鍏抽敭鍊兼帓搴忥紝鍗充嬌鏌ユ壘澶辮觸涔熶笉闇瑕侀亶鍘嗘暣涓摼琛ㄣ傝繖灝辨槸鏁版嵁緇撴瀯涓殑鐩鎬簰鐭涚浘鐨勪袱涓棶棰橈紝搴旀牴鎹疄闄呮儏鍐靛崗璋冦?br>#include<stdio.h>
#define PRIME 99991
struct hashnode
{
    int key;
    int num;
    int next;
}a[1000005];
int b[1000005];
int hashl;
int hash(int num)
{
    int i;
    i=num%PRIME;
    while(a[i].next!=-1)
    {
        if(num>a[a[i].next].key)     //渚嬪hash琛ㄤ腑宸叉湁8錛屽悗闈㈠張鎻掑叆99999鏃訛紝閭d箞99999>8,闇瑕佺粰99999閲嶆柊鍒嗛厤                                                                           涓涓笅鏍囷紝鍗砲ashl錛屽嵆鍓嶉潰鎻愬埌鐨勫紑鏁e垪娉曡В鍐沖啿紿?br>            break;
        else if(num==a[a[i].next].key)    //渚嬪hash琛ㄤ腑宸叉湁8錛屽悗闈㈠張鎻掑叆8鏃訛紝榪欐槸鍙num++
            return a[i].next;
        i=a[i].next;                               //榪欏彞鐢ㄤ簬鏌ユ壘錛屽鏋滃搱甯岃〃涓凡鏈?鍜?9999錛岄偅涔堜綘瑕佹壘8鏃禷[8].next鎸囧悜鐨勬槸杈冨ぇ鐨?9999錛岄偅涔堜綘灝卞繀欏繪部鐫next璧頒笅鍘伙紝鍥犱負(fù)榪欎釜鎵璋撶殑閾捐〃鏄寜鍑忓皬鐨勯『搴忔帓搴忕殑銆傛渶緇堣蛋鍒皉eturn a[i].next鎺ㄥ嚭while 寰幆
    }
    a[hashl].key=num;
    a[hashl].next=-1;
    a[hashl].num=0;
    a[hashl].next=a[i].next;
    a[i].next=hashl;
    hashl++;                                //浠ヤ笂6琛岀敤浜庣涓嬈℃彃鍏ュ厓绱狅紙鍗硍hile寰幆鏈墽琛岋級鎴杦hile寰幆break閫鍑虹殑鎻掑叆
    return hashl-1;
}

int main()
{
    int n,i,tmp,left,ans;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<PRIME;i++)
            a[i].next=-1;
        hashl=PRIME;
        left=0;
        ans=1;
        scanf("%d",&b[0]);
        tmp=hash(b[0]);
        a[tmp].num++;
        for(i=1;i<n;i++)
        {
            scanf("%d",&b[i]);
            tmp=hash(b[i]);
            a[tmp].num++;
            if(a[tmp].num<=1)     //鎻掑叆鐨勬暟瀛椾互鍓嶆病鏈夊嚭鐜拌繃錛岃偗瀹氬寘鍚湪ans閲?br>            {
                ans=i-left+1;
                continue;
            }                        
            while(1)                     //瀵瑰簲浜巌f鐨別lse,鍗砤[tmp].num>=2錛屽嵆鎻掑叆鐨勬暟瀛椾互鍓嶅嚭鐜拌繃銆傚鏋滄槸鍦╨eft浣嶇疆鍑虹幇榪囷紝鍒檒eft鍙崇Щ錛涘鏋滄槸鍦?#8220;left鍙寵竟錛宨宸﹁竟”鍑虹幇榪囷紝鍒欒鏄庣洰鍓嶇殑i-left+1鍜宎ns閮藉彲浠ュ寘鎷叏閮ㄧ殑鐭ヨ瘑鐐癸紝褰撶劧鍙栧皬鐨勪簡錛?nbsp;  
            {
                tmp=hash(b[left]);
                if(a[tmp].num<=1)
                    break;
                a[tmp].num--;
                left++;
            }
            if(ans>i-left+1)
                ans=i-left+1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


鏈枃鏉ヨ嚜CSDN鍗氬錛岃漿杞借鏍囨槑鍑哄錛?a >http://blog.csdn.net/cugbliang/archive/2008/06/01/2497376.aspx



luis 2009-07-01 13:00 鍙戣〃璇勮
]]>
久久精品国产亚洲AV电影| 久久久精品人妻一区二区三区蜜桃| 88久久精品无码一区二区毛片 | 亚洲日韩中文无码久久| 久久发布国产伦子伦精品| 精品永久久福利一区二区| 精品国产热久久久福利| 国产精品99久久久久久www| 久久九九兔免费精品6| 久久婷婷国产综合精品| 久久精品无码免费不卡| 伊人久久综合成人网| 久久久久99精品成人片直播| www亚洲欲色成人久久精品| 午夜精品久久久久久影视riav| 国产一区二区三区久久| 一本久久a久久精品亚洲| 精品一区二区久久久久久久网站| 武侠古典久久婷婷狼人伊人| 久久免费高清视频| 91久久精一区二区三区大全| 亚洲中文字幕无码一久久区 | 亚洲色欲久久久久综合网| 人人狠狠综合久久亚洲婷婷| 中文字幕精品无码久久久久久3D日动漫| 久久婷婷成人综合色综合| 天天影视色香欲综合久久| 亚洲一区中文字幕久久| 久久超乳爆乳中文字幕| 精品久久久久久国产| 色天使久久综合网天天| 日韩乱码人妻无码中文字幕久久| 国产亚洲成人久久| 久久免费美女视频| 久久亚洲综合色一区二区三区| 性色欲网站人妻丰满中文久久不卡| 国产亚洲精品久久久久秋霞| 日韩久久久久中文字幕人妻| 欧美久久天天综合香蕉伊| 九九热久久免费视频| 久久亚洲AV无码西西人体|