Ultraviolet A-123 Searching Quickly

Source: Internet
Author: User

Ultraviolet A-123 Searching Quickly

Question Link

This question is to give a series of ignore words (all in lower case), end with: And then input a series of text, each line does not include the ignore word as a keyword, (Not case sensitive to ignore words), and then sort the output. Several keywords may appear in each row, which are output sequentially. If several rows contain the same keyword, they are output in the order of input, and the rest are output in the Lexicographic Order. In the output, except for the keywords in upper case, the others must be in lower case.

This question takes a long time, but fortunately 1A.

My idea is to first convert all the text into lowercase letters, then retrieve the keyword, save the row where the initial position is and where the line appears, and then sort the keywords, mark the corresponding keywords in uppercase for output. The corresponding output is good.

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
Struct node {char s [10000]; int index, p;} word [10000]; // location of the row where the storage keyword is initially stored int cmp (const void * _, const void * _ B) {struct node * a = (node *) _ a; struct node * B = (node *) _ B; if (strcmp (a-> s, b-> s) = 0 & a-> index! = B-> index) return a-> index-B-> index; else if (strcmp (a-> s, B-> s) = 0 & a-> index = B-> index) return a-> p-B-> p; else return strcmp (a-> s, b-> s);} // first sort by the initial row subscript, and then rank char s1 [100] [150] In the lexicographically sorted order. // ignorechar s2 [250] [10000]; // titlechar str [10000]; // temporarily Save the keyword bool ans [10000]; // mark the array int main () {// freopen ("a.txt", "r", stdin); int n = 0, m = 0, I, j, x = 0, jj; while (~ Scanf ("% s", s1 [n]) {if (strcmp (s1 [n], ":") = 0) break; n ++ ;} getchar (); // for (I = 0; I
     
      
= 'A' & s2 [I] [j] <= 'Z') s2 [I] [j] + = 32 ;}/ * for (I = 0; I
      
        = 'A' & s2 [I] [j] <= 'Z') str [k ++] = s2 [I] [j]; else {// printf ("% s \ n", str); flag = 0; for (jj = 0; jj
       
        

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.