Test instructions
Enter an article that outputs up to 10 words
Does not include existing words in old
The same number of occurrences by dictionary order size
Simple simulation, number of map records
There's no pit.
and sort it out.
Use String to compare dictionary order sizes directly
#include <cstdio>#include<cstring>#include<string>#include<iostream>#include<algorithm>#include<map>#include<math.h>using namespacestd;Chars[205],m[]={"</article>"};structnode{stringA; intv;} p[150005];BOOLCMP (node A,node b) {if(A.V==B.V)returna.a<C.A; returnA.v>B.V;}intMain () {intI,j,n; intT; scanf ("%d",&T); while(t--) {scanf ("%s", s); Map<string,int>F; while(SCANF ("%s", s)) { intL=strlen (s); for(i=0; i<l;i++) { if(s[i]>='A'&&s[i]<='Z') s[i]+= +; } if(s[0]=='<') Break; f[s]=-1; } scanf ("%s", s); intCnt=0; while(SCANF ("%s", s)) { intL=strlen (s); if(l==Ten) { for(i=0; i<l;i++) { if(S[i]==m[i])Continue; Break; } if(i==Ten) Break; } stringtp=""; for(i=0; i<l;i++) { if(s[i]>='A'&&s[i]<='Z') s[i]+= +; if(s[i]>='a'&&s[i]<='Z') TP+=S[i]; Else { if(tp=="")Continue; if(f[tp]==0) {F[TP]=++CNT; P[CNT].A=TP; P[CNT].V=1; } ElseP[F[TP]].V++; TP=""; } } if(tp=="")Continue; if(f[tp]==0) {F[TP]=++CNT; P[CNT].A=TP; P[CNT].V=1; } ElseP[F[TP]].V++; } sort (P+1, p+1+cnt,cmp); for(i=1; i<=Ten&&i<=cnt;i++) cout<<p[i].a<<Endl; cout<<Endl; } return 0;}
HDU Computer College College Student Program Design Contest (1008) Study Words