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