Computer College Undergraduate Program Design Contest (2015 ') Study Words

Source: Internet
Author: User
Tags strcmp
Study Words Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 195 accepted Submission (s): 66


Problem Description Learning Chinese is isn't easy, vocabulary troubles me a lot.
One day a idea came up to me:i download a article every day, choose the "most" popular new words to study.
A word ' s popularity is calculated by the number of its occurrences.
Sometimes two or words have the same occurrences, and then the word with a smaller lexicographic has a higher popular ity.
Input T in the the ' the '.
Each case has two parts.
<oldwords>
...
</oldwords>
<article>
...
</article>
Between <oldwords> and </oldwords> are some old words (no more than 10000) I have already learned, which is, I Don ' t need to learn them any more.
Words between <oldwords> and </oldwords> contain letters (' a ' ~ ' Z ', ' a ' ~ ' Z ') only, separated by blank characters (', ' \ n ' or ' \ t ').
Between <article> and </article> is a article (contains fewer than 1000000).
Only continuous letters (' a ' ~ ' Z ', ' a ' ~ ' Z ') to make up a word. Thus words like "don ' t" are regarded as two words "Don" and "T", which that ' s OK.
Treat the uppercase as lowercase, so "I" equals to "." No words would be longer than 100.
As the article is downloaded from the Internet, it may contain some Chinese words, which I don ' t need to study.
Output for each case, output to the top new words I should study, one into a line.
If there are fewer than new words, output all of them.
Output a blank line for each case.
Sample Input
2 <oldwords> How aRe your </oldwords> <article>--how old aRe for you? --twenty. </article> <oldwords> Google cn huluobo Net I </oldwords> <article> article content: I love Google,dropbox,fi Refox very much. Everyday I Open My Computer, open Firefox, and enjoy surfing on the inter-net. But The It ' s strange that searching ' Huluobo ' is unavail-able. What ' s wrong with "Huluobo"? </article>
Sample Output
Old Twenty Firefox open s able and but computer days Dropbox enjoy

today is the last Sunday of 2015, I used a good long long time to do this problem, test the answer should not be wrong, but ... so sad,
Do not want to revise .... Let it always be wrong. The following is the correct answer oh.


#include <cstdio> #include <cstring> #include <map> #include <string> #include <algorithm
> Using namespace std;
int T;
Char s[100+10];
Char r[100+10];
map<string,int>m;
    struct Dan {char s[100+10];
int num;
}D[1000000+10];
int sum;
int tot;
    BOOL CMP (const Dan&a,const dan&b) {if (A.num==b.num) return strcmp (A.S,B.S) <0;
Return a.num>b.num; //turn to lowercase void F () {for (int i=0;s[i];i++) if (s[i]>= ' a ' &&s[i]<= ' Z ') s[i]=s[i]-' a ' + ' a '
;
    } void Work () {int Len=strlen (s);
    tot=0;
        for (int i=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;
    }} void Work2 () {int Len=strlen (s);
    tot=0;
        for (int i=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) str
                    CPY (D[SUM++].S,R);
                m[r]++;
        }} tot=0;
    int main () {scanf ("%d", &t);
        while (t--) {int flag=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 (int i=0;i<sum;i++) D[I].NUM=M[D[I].S];
        Sort (d,d+sum,cmp); for (int i=0;i<min (10,sum); i++) printf ("%s\n", D[I].S);
    printf ("\ n");
return 0;
 }


@ hold read "@☆ but beg" ❤ "Ann ★ Next time we do will be better ....
for what this time the topic is in English .... Qaq ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.