#include #include #include #include #include #include #define j1 dada using namespace std; int n, i1, j1, resl, resr, vsize; string s, res="", fres; bool better=false; char orig[26]={'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm'}; bool used[75], fromS[75]; int saveIdx[75], order[26]={0, 1, 11, 10, 19, 20, 21, 12, 2, 3, 13, 22, 23, 14, 4, 5, 15, 24, 25, 16, 6, 7, 8, 9, 18, 17}, dist[26][26]; pair mp[75]; int curr, mcurr=-1, froml, fromr, lel; clock_t tstart; void init() { res=""; vsize=0; for(int i=49; i<=74; ++i) { used[i]=false; } } void fills() { for(int i=0; imp[orig[j]-'0'].first || !fromS[res[j]-'0']) { continue; } i1=i, j1=j; curr=0; for(int k=0; kmp[orig[i1]-'0'].first) { curr+=fromr; j1=saveIdx[s[k]-'0']; } else { curr+=froml; i1=saveIdx[s[k]-'0']; } } } if(mcurr==-1) { mcurr=curr; resl=i+1, resr=j+1; } else { if(mcurr>curr) { mcurr=curr; resl=i+1, resr=j+1; } } } } } void holySol() { init(); vsize=0; for(int i=0; i<26; ++i) { res+='A'; } for(int i=0; i>n>>s; mp['q'-'0'].first=85, mp['q'-'0'].second=140, mp['w'-'0'].first=123, mp['w'-'0'].second=140; mp['e'-'0'].first=161, mp['e'-'0'].second=140, mp['r'-'0'].first=199, mp['r'-'0'].second=140; mp['t'-'0'].first=237, mp['t'-'0'].second=140, mp['y'-'0'].first=275, mp['y'-'0'].second=140; mp['u'-'0'].first=313, mp['u'-'0'].second=140, mp['i'-'0'].first=351, mp['i'-'0'].second=140; mp['o'-'0'].first=389, mp['o'-'0'].second=140, mp['p'-'0'].first=427, mp['p'-'0'].second=140; mp['a'-'0'].first=95, mp['a'-'0'].second=179, mp['s'-'0'].first=133, mp['s'-'0'].second=179; mp['d'-'0'].first=171, mp['d'-'0'].second=179, mp['f'-'0'].first=209, mp['f'-'0'].second=179; mp['g'-'0'].first=247, mp['g'-'0'].second=179, mp['h'-'0'].first=285, mp['h'-'0'].second=179; mp['j'-'0'].first=324, mp['j'-'0'].second=179, mp['k'-'0'].first=362, mp['k'-'0'].second=179; mp['l'-'0'].first=400, mp['l'-'0'].second=179, mp['z'-'0'].first=122, mp['z'-'0'].second=219; mp['x'-'0'].first=160, mp['x'-'0'].second=219, mp['c'-'0'].first=198, mp['c'-'0'].second=219; mp['v'-'0'].first=236, mp['v'-'0'].second=219, mp['b'-'0'].first=275, mp['b'-'0'].second=219; mp['n'-'0'].first=313, mp['n'-'0'].second=219, mp['m'-'0'].first=351, mp['m'-'0'].second=219; for(int i=49; i<=74; ++i) { mp[i].first-=84, mp[i].second-=139; } getDist(); fills(); holySol(); helloo(); cout<