Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
严重求助,请教诸大牛我的代码哪有问题?(暴搜)#include <stdio.h> #include <string.h> #include <memory.h> char s[27],r[27]; int used[27]; int Judge(int pos) { if (pos>=26) return 1; if (r[pos]>='A'&&r[pos]<='Z') return Judge(pos+1); else { char kr[27],ch,tc; int kusd[27],i,tp; for (i=0;i<27;i++) kusd[i]=used[i]; strcpy(kr,r); for (ch='A';ch<='Z';ch++) if (!used[ch-'A']) { tp=pos;tc=ch; while (1) { if (r[tp]>='A'&&r[tp]<='Z') { if (r[tp]==tc) break; else goto CONTINUE; } else if (used[tc-'A']) goto CONTINUE; r[tp]=tc; used[tc-'A']=1; tc=s[tp]; tp=r[tp]-'A'; } if (Judge(pos+1)) return 1; CONTINUE: strcpy(r,kr); for (i=0;i<27;i++) used[i]=kusd[i]; } } return 0; } void read() { int TestCase; scanf("%d",&TestCase); while (TestCase--) { memset(used,0,sizeof(used)); memset(s,0,sizeof(s)); memset(r,0,sizeof(r)); scanf("%s",&s); if (Judge(0)) printf("Yes\n"); else printf("No\n"); } } int main() { read(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator