#include <cstdio>#include<cstring>#include<map>#include<string>#include<algorithm>using namespacestd;intT;Chars[ -+Ten];Charr[ -+Ten];map<string,int>m;structdan{Chars[ -+Ten]; intnum;} d[1000000+Ten];intsum;inttot;BOOLcmpConstDan&a,Constdan&b) { if(A.num==b.num)returnstrcmp (A.S,B.S) <0; returnA.num>B.num;}//Turn lowercasevoidF () { for(intI=0; s[i];i++) if(s[i]>='A'&&s[i]<='Z') S[i]=s[i]-'A'+'a';}voidWork () {intlen=strlen (s); Tot=0; for(intI=0; i<=len;i++) { if(s[i]>='a'&&s[i]<='Z') r[tot++]=S[i]; Else{R[tot]=' /'; if(strlen (R) >0) m[r]=-1; Tot=0; } }}voidWork2 () {intlen=strlen (s); Tot=0; for(intI=0; i<=len;i++) { if(s[i]>='a'&&s[i]<='Z') r[tot++]=S[i]; Else{R[tot]=' /'; if(strlen (R) >0) { if(m[r]!=-1) { if(m[r]==0) strcpy (d[sum++].s,r); M[R]++; }} tot=0; } }}intMain () {scanf ("%d",&T); while(t--) { intflag=0; M.clear (); Sum=0; while(1) {scanf ("%s", s); if(strcmp (s),"<oldwords>")==0) {flag=1;Continue;} if(strcmp (s),"</oldwords>")==0) {flag=2;Continue;} if(strcmp (s),"<article>")==0) {flag=3;Continue;} if(strcmp (s),"</article>")==0) Break; if(flag==1) {F (); Work (); } if(flag==3) {F (); Work2 (); } } for(intI=0; i<sum;i++) d[i].num=M[D[I].S]; Sort (d,d+sum,cmp); for(intI=0; I<min (Ten, sum); i++) printf ("%s\n", D[I].S); printf ("\ n"); } return 0;}
Computer College College Student Program Design Competition (1008) Study Words