锘??xml version="1.0" encoding="utf-8" standalone="yes"?>人妻少妇久久中文字幕,久久精品国内一区二区三区,日韩人妻无码一区二区三区久久
http://www.shnenglu.com/luyulaile/category/11068.htmlI can zh-cn Sun, 05 Jul 2009 17:04:43 GMT Sun, 05 Jul 2009 17:04:43 GMT 60 poj 1611 the suspect 騫舵煡闆?/title> http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.htmlluis luis Fri, 03 Jul 2009 08:51:00 GMT http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html http://www.shnenglu.com/luyulaile/comments/89172.html http://www.shnenglu.com/luyulaile/archive/2009/07/03/89172.html#Feedback 0 http://www.shnenglu.com/luyulaile/comments/commentRss/89172.html http://www.shnenglu.com/luyulaile/services/trackbacks/89172.html Description
Description
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. 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). Once a member in a group is a suspect, all members in the group are suspects. 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.
Input
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. A case with n = 0 and m = 0 indicates the end of the input, and need not be processed.
Output
For each case, output the number of suspects in one line.
Sample Input
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
Sample Output
4
1
1
鍚ず1錛屼竴瀹氭敞鎰忓垵濮嬪寲甯︽潵鐨勫獎鍝嶏紝1錛屾槸浠涔堝湴鏂瑰垵濮嬪寲錛?錛屽墠涓涓猚ase涓嶅簲褰撳涓嬩竴涓犳垚褰卞搷 2錛屾湁灞傛鎬х殑闂涓瀹氳澶勭悊濂斤紝涓嶈 3錛屼緥濡傞噸澶嶆暟鎹笉鑳介噸澶嶅垵濮嬪寲銆?br> cin>>t; if(father[t]<0)//蹇呬笉鍙皯 father[t]=t; #include<iostream> #include<cstdlib> using namespace std; int rank[30001]; int father[30001]; void UNION(int a,int b) { if(a==b)return; else { if(rank[a]<rank[b]) { father[b]=father[a]; } else { father[a]=father[b]; } } } int Find(int t) { int tmp=t,x; while(father[tmp]!=tmp) { tmp=father[tmp]; } while(t!=father[t]) { x=t; t=father[x]; father[x]=tmp; }
return t; } int main() { freopen("s.txt","r",stdin); freopen("key.txt","w",stdout); int i,j,nt,t1,t,result; while(cin>>i>>j,i||j) { result=0; memset(rank,1,sizeof(rank)); memset(father,-1,sizeof(father)); rank[0]=0; father[0]=0; for(int k=0;k<j;k++) { cin>>nt; cin>>t1; rank[t1]=t1; if(father[t1]<0) father[t1]=t1; for(int m=1;m<nt;m++) { cin>>t; rank[t]=t; if(father[t]<0) father[t]=t; UNION(Find(t1),Find(t)); } } for(int l=0;l<i;l++) { if(father[l]>=0) { if(!Find(l)) result++; } } cout<<result<<endl; }
//system("PAUSE"); return 0; }
]]>鍝堝笇琛?poj 3320 Jessica's Reading Problem http://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.htmlluis luis Wed, 01 Jul 2009 05:00:00 GMT http://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.html http://www.shnenglu.com/luyulaile/comments/88982.html http://www.shnenglu.com/luyulaile/archive/2009/07/01/88982.html#Feedback 0 http://www.shnenglu.com/luyulaile/comments/commentRss/88982.html http://www.shnenglu.com/luyulaile/services/trackbacks/88982.html poj 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璧頒笅鍘伙紝鍥犱負榪欎釜鎵璋撶殑閾捐〃鏄寜鍑忓皬鐨勯『搴忔帓搴忕殑銆傛渶緇堣蛋鍒皉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
]]>
久久se这里只有精品 |
日韩欧美亚洲综合久久 |
yy6080久久 |
久久亚洲中文字幕精品一区 |
国内精品久久久久影院薰衣草
|
性做久久久久久久久久久 |
久久经典免费视频 |
国产69精品久久久久99尤物 |
亚洲伊人久久大香线蕉综合图片 |
久久久久免费看成人影片 |
欧美激情精品久久久久久久 |
国产精品99久久精品 |
久久伊人五月丁香狠狠色 |
精品国际久久久久999波多野 |
亚洲精品乱码久久久久久中文字幕 |
久久亚洲高清综合 |
国产产无码乱码精品久久鸭 |
久久久黄色大片 |
国产福利电影一区二区三区久久老子无码午夜伦不
|
精品久久久久久国产 |
久久久久成人精品无码中文字幕
|
97精品国产91久久久久久 |
久久婷婷五月综合色99啪ak |
久久亚洲AV成人无码电影 |
久久久久久精品免费看SSS |
欧美成a人片免费看久久 |
999久久久无码国产精品 |
中文精品久久久久人妻不卡 |
久久亚洲欧洲国产综合 |
国产精品成人99久久久久91gav |
久久A级毛片免费观看 |
午夜天堂av天堂久久久 |
狠狠色丁香久久婷婷综合 |
97精品国产97久久久久久免费 |
日韩美女18网站久久精品 |
久久久久久久99精品免费观看 |
久久国产午夜精品一区二区三区 |
蜜桃麻豆www久久国产精品 |
久久国产乱子伦精品免费午夜 |
久久综合九色综合97_久久久 |
久久久精品免费国产四虎 |