The meaning is to convert the first string to the second string. Two operations are supported, one is to delete, and the other is to change the character position.
Simple string operation !!
The AC code is as follows:
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#define M 50010#define inf 100000000using namespace std;char a[1005],b[1005];int la,lb;bool automaton(){ int i=0,j=0,flag=0; while(a[i]!='\0') { if(a[i]==b[j]) { i++; j++; flag++; } else { i++; } } if(flag==lb) return true; return false;}int main(){ int i,j; int c[500],d[500]; cin>>a; cin>>b; la=strlen(a); lb=strlen(b); if(lb>la) { printf("need tree\n"); return 0; } if(la==lb) { memset(c,0,sizeof c); memset(d,0,sizeof d); for(i=0;i<la;i++) c[a[i]]++; for(i=0;i<lb;i++) d[b[i]]++; int ans=0; for(i='a';i<='z';i++) if(c[i]==d[i]) ans++; if(ans==26) { printf("array\n"); return 0; } } else if(automaton()) { printf("automaton\n"); return 0; } memset(c,0,sizeof c); memset(d,0,sizeof d); int anss=0; for(i=0;i<lb;i++) d[b[i]]++; for(i=0;i<la;i++) c[a[i]]++; for(i='a';i<='z';i++) if(d[i]!=0) anss++; int an=0; for(i='a';i<='z';i++) if(c[i]>=d[i]&&d[i]!=0) an++; //cout<<an<<" "<<anss<<endl; if(an==anss) { printf("both\n"); return 0; } printf("need tree\n"); return 0;}