#include<iostream> #include<fstream> #include<cstring> using namespace std; struct cod { char ch; char simbol[6]; }x[27]; struct cuvinte { char cuv_morse[100000*5]; }v_cuv[1000]; int main() { ifstream f("input.txt"); ofstream g("output.txt"); int i,j,N,nr,nrmax=0; char s[100000]; for(i=1;i<=26;i++) { f>>x[i].ch; f.get(); f.get(x[i].simbol,5); } f>>N; for(i=1;i<=N;i++) { f>>s; for(j=0;j<strlen(s);j++) strcat( v_cuv[i].cuv_morse , x[s[j]-'a'+1].simbol ); } //for(i=1;i<=N;i++) //cout<<v_cuv[i].cuv_morse<<endl; //numar sirul care apare de cel mai multe ori for(i=1;i<N;i++) { nr=1; for(j=i+1;j<=N;j++) { /*ok=1; for(c=0;c<strlen(v_cuv[i].cuv_morse) && c<strlen(v_cuv[j].cuv_morse) && ok;c++) if(v_cuv[i].cuv_morse[c]!=v_cuv[j].cuv_morse[c]) ok=0; if(ok==1) nr++;*/ //echivalent cu if(strcmp(v_cuv[i].cuv_morse,v_cuv[j].cuv_morse)==0) nr++; } if(nr>nrmax) nrmax=nr; } g<<nrmax; return 0; }