Submission #20146

#TimeUsernameProblemLanguageResultExecution timeMemory
20146ansol1111구간 성분 (KOI15_interval)C++98
0 / 100
0 ms1084 KiB
#include<stdio.h> #include<string.h> #include<memory.h> char a[1505], b[1505]; int na, nb, checka[30], checkb[30], l; int input() { scanf("%s",&a[1]); scanf("%s",&b[1]); na=strlen(&a[1]); nb=strlen(&b[1]); return 0; } int process() { int k, i, j, p; if(na>nb) { for(k=nb ; k>=1 ; k--) { for(i=1 ; i<=k ; i++) { checka[a[i]-'a'+1]++; checkb[b[i]-'a'+1]++; } for(i=1 ; i<=26 ; i++) { if(checka[i]!=checkb[i]) break; } if(i==27) { l=k; break; } for(i=k+1 ; i<=na ; i++) { checka[a[i-k]-'a'+1]--; checka[a[i]-'a'+1]++; for(j=1 ; j<=26 ; j++) { if(checka[j]!=checkb[j]) break; } if(j==27) { l=k; break; } } if(i!=na+1) break; memset(checka,0,sizeof(checka)); for(i=1 ; i<=k ; i++) { checka[a[i]-'a'+1]++; } for(i=k+1 ; i<=nb ; i++) { checkb[b[i-k]-'a'+1]--; checkb[b[i]-'a'+1]++; for(j=1 ; j<=26 ; j++) { if(checka[j]!=checkb[j]) break; } if(j==27) { l=k; break; } for(j=k+1 ; j<=na ; j++) { checka[a[j-k]-'a'+1]--; checka[a[j]-'a'+1]++; for(p=1 ; p<=26 ; p++) { if(checka[p]!=checkb[p]) break; } if(p==27) { l=k; break; } } if(j!=na+1) break; memset(checka,0,sizeof(checka)); for(j=1 ; j<=k ; j++) { checka[a[j]-'a'+1]++; } } if(i!=nb+1) break; } } if(na<=nb) { for(k=na ; k>=0 ; k--) { for(i=1 ; i<=k ; i++) { checka[a[i]-'a'+1]++; checkb[b[i]-'a'+1]++; } for(i=1 ; i<=26 ; i++) { if(checka[i]!=checkb[i]) break; } if(i==27) { l=k; break; } for(i=k+1 ; i<=nb ; i++) { checkb[b[i-k]-'a'+1]--; checkb[b[i]-'a'+1]++; for(j=1 ; j<=26 ; j++) { if(checka[j]!=checkb[j]) break; } if(j==27) { l=k; break; } } if(i!=nb+1) break; memset(checkb,0,sizeof(checkb)); for(i=1 ; i<=k ; i++) { checkb[b[i]-'a'+1]++; } for(i=k+1 ; i<=na ; i++) { checka[a[i-k]-'a'+1]--; checka[a[i]-'a'+1]++; for(j=1 ; j<=26 ; j++) { if(checka[j]!=checkb[j]) break; } if(j==27) { l=k; break; } for(j=k+1 ; j<=nb ; j++) { checkb[b[j-k]-'a'+1]--; checkb[b[j]-'a'+1]++; for(p=1 ; p<=26 ; p++) { if(checka[p]!=checkb[p]) break; } if(p==27) { l=k; break; } } if(j!=nb+1) break; memset(checkb,0,sizeof(checkb)); for(j=1 ; j<=k ; j++) { checkb[b[j]-'a'+1]++; } } if(i!=na+1) break; } } return 0; } int output() { printf("%d\n",l); return 0; } int main() { input(); process(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...