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