[暴力]JZOJ 5817 抄代码
分析
搞个类似出度的数组就能AC,细节较多
然后有反例可以轻易hack掉AC代码:
1
abcdefghijklmnopqrstuvwxyz
zyxwvutsrqponmlkjihgfedcba
不过貌似数据非常水,题解也是这种可以被hack掉的代码,所以= =
#include <iostream> #include <cstdio> #include <cstring> #include <memory.h> using namespace std; char s1[1101],s2[1101]; int len1,len2; bool b[27]; int d[27][27]; int t; int main() { freopen("copycat.in","r",stdin); freopen("copycat.out","w",stdout); scanf("%d\n",&t); while (t--) { len1=len2=0; char c; do { scanf("%c",&c); s1[len1++]=c; } while (c!='\n'&&c!='\r'); len1--; do { scanf("%c",&c); s2[len2++]=c; } while (c!='\n'&&c!='\r'); len2--; if (len1!=len2) { printf("0\n"); continue; } memset(b,0,sizeof b);memset(d,0,sizeof d); bool p=1; for (int i=0;i<len1;i++) { if ('a'<=s1[i]&&s1[i]<='z') { if ('a'>s2[i]||s2[i]>'z') { printf("0\n"); p=0; break; } if (s1[i]==s2[i]) continue; if (b[s1[i]-'a']&&!d[s1[i]-'a'][s2[i]-'a']) { printf("0\n"); p=0; break; } b[s1[i]-'a']=d[s1[i]-'a'][s2[i]-'a']=1; } else { if ('a'<=s2[i]&&s2[i]<='z') { printf("0\n"); p=0; break; } if (s1[i]!=s2[i]) { printf("0\n"); p=0; break; } } } if (p) printf("1\n"); } fclose(stdin);fclose(stdout); }
在日渐沉没的世界里,我发现了你。