挺魔的
反正我考场上想不到233333333333333
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define rint register int using std::sort; using std::cin; template <class T>inline void read(T &X) { X=0;int W=0;char ch=0; while(!isdigit(ch))W|=ch=='-',ch=getchar(); while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); X=W?-X:X;return; } int n,m,t,tot1,tot2; int ou[100010],next[100010],ji[100010],tmp; char S[100010],T[100010]; bool ok1,ok2,ok; int main() { freopen("vanusee.in","r",stdin); freopen("vanusee.out","w",stdout); read(t); while (t--) { ok1=ok2=ok=0; cin>>S+1; cin>>T+1; n=strlen(S+1),m=strlen(T+1); tot1=tot2=0; for (rint i=2,j=0;i<=m;i++) { while (T[i]!=T[j+1]&&j) j=next[j]; if (T[i]==T[j+1]) j++; next[i]=j; } for (rint i=1,j=0;i<=n;i++) { while (S[i]!=T[j+1]&&j) j=next[j]; if (S[i]==T[j+1]) j++; if (j==m) { tmp=n-i+m-i; if (!((n-m)%2)) ou[++tot1]=tmp; else ji[++tot2]=tmp; j=next[j]; } } if ((n-m)%2) { sort(ji+1,ji+tot2+1); for(rint i=2;i<=tot2;i++) if(ji[i]-ji[i-1]==2) ou[++tot1]=ji[i]-1; } for (rint i=1;i<=tot1;i++) { if (!ou[i]){ok=1;break;} if (ou[i]==2) ok1=1; if (ou[i]==-2) ok2=1; } if (ok) {printf("pty ");continue;} if (!ok1 || !ok2) printf("cqf "); else printf("pty "); } }