"Hdoj" 1483 Automatic Correction of misspellings

Source: Internet
Author: User

Water simulation problem.

1 /*1483*/2#include <cstdio>3#include <cstring>4#include <cstdlib>5 6 #defineMAXN 100057 8typedefstruct {9     Chars[ -];Ten     intLen; One } node_t; A  - node_t NODE[MAXN]; - Chars[ -]; the intLen, V; - intN, M; - intFlag; -  + intAbsintx) { -     returnx<0? -x:x; + } A  at intMinintAintb) { -     returnA<b?a:b; - } -  - intMaxintAintb) { -     returnA<b?a:b; in } -  to voidsolve () { +     intI, J, K, p, TMP; -     intstack[ -], top; theFlag =2; *      $     //Check if is correctPanax Notoginseng      for(i=0; flag&&i<n; ++i) { -         if(node[i].len==Len) { the             //Swap 2 char or 1 char wrong or just the same +K =0; Atop =0; the              for(j=0; k<=2&&j<len; ++j) { +                 if(Node[i].s[j]! =S[j]) { -stack[top++] =J; $++K; $                 } -             } -             if(k = =0) { theFlag =0; -v =i;Wuyi                  Break; the}Else if(k==1&& flag>1) { -Flag =1; Wuv =i; -}Else if(k==2&& flag>1) { About                 if(node[i].s[stack[0]]==s[stack[1]] && node[i].s[stack[1]]==s[stack[0]]) { $Flag =1; -v =i; -                 } -             } A}Else if(flag>1&& node[i].len-len==1) { +             //One letter is missing the             BOOLSt =true; -              for(j=k=0; k<node[i].len; ++k) { $                 if(Node[i].s[k] = =S[j]) the++J; the                 Else if(ST) theSt =false; the                 Else -                      Break; in             } the             if(k >=Node[i].len) { theFlag =1; Aboutv =i; the             } the}Else if(flag>1&& len-node[i].len==1) { the             //Too much +             BOOLSt =true; -              for(k=0, j=0; j<len; ++j) { the                 if(Node[i].s[k] = =S[j])Bayi++K; the                 Else if(ST) theSt =false; -                 Else -                      Break; the             } the             if(j>=Len) { theFlag =1; thev =i; -             } the         } the     } the }94  the intMain () { the     intI, J, K, TMP; the     98 #ifndef Online_judge AboutFreopen ("data.in","R", stdin); -     #endif101     102      while(SCANF ("%d", &n)! =EOF) {103          for(i=0; i<n; ++i) {104scanf"%s", NODE[I].S); theNode[i].len =strlen (NODE[I].S);106         }107scanf"%d", &m);108          while(m--) {109scanf"%s", s); theLen =strlen (s);111              the solve ();113             if(Flag = =2) theprintf"%s is unknown\n", s); the             Else if(Flag = =0) theprintf"%s is correct\n", s);117             Else if(Flag = =1)118printf"%s is a misspelling of%s\n", S, node[v].s);119         } -     }121     122     return 0;123}

"Hdoj" 1483 Automatic Correction of misspellings

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.