锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久国产精品成人免费,国产精品99久久精品爆乳,国产精品成人99久久久久91gav 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璧頒笅鍘伙紝鍥犱負(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
]]>
天堂无码久久综合东京热 |
久久精品中文字幕无码绿巨人 |
国产成人香蕉久久久久 |
狠狠色综合网站久久久久久久 |
久久久久亚洲av成人无码电影 |
久久婷婷五月综合色奶水99啪 |
久久亚洲精品成人AV |
久久精品亚洲福利 |
久久99精品国产麻豆 |
亚洲欧洲久久久精品 |
一本大道久久a久久精品综合 |
久久亚洲AV成人无码 |
国产精自产拍久久久久久蜜 |
浪潮AV色综合久久天堂 |
亚洲а∨天堂久久精品 |
国产精品成人久久久久三级午夜电影 |
亚洲а∨天堂久久精品 |
精品久久人人妻人人做精品 |
国产精品一久久香蕉国产线看
|
久久99精品国产99久久 |
亚洲欧美伊人久久综合一区二区 |
国产精品无码久久久久 |
97久久香蕉国产线看观看 |
久久精品国产亚洲αv忘忧草 |
国产精品美女久久久久av爽 |
www.久久热 |
国产综合久久久久久鬼色 |
伊人久久精品无码二区麻豆 |
亚洲国产成人久久综合区 |
激情五月综合综合久久69 |
亚洲天堂久久精品 |
国产精品VIDEOSSEX久久发布 |
91秦先生久久久久久久 |
久久99国产精品二区不卡 |
久久不见久久见免费视频7 |
久久精品无码午夜福利理论片 |
国产亚洲精久久久久久无码77777 |
久久精品国产99国产精品亚洲 |
久久亚洲精品无码aⅴ大香 |
99精品国产免费久久久久久下载 |
亚洲伊人久久综合中文成人网 |