Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("bacon.in");
- ofstream fout("bacon.out");
- int C;
- char mess[50005], ha[6];
- char *codes[] = {
- "AAAAA", "AAAAB", "AAABA", "AAABB", "AABAA",
- "AABAB", "AABBA", "AABBB", "ABAAA", "ABAAB",
- "ABABA", "ABABB", "ABBAA", "ABBAB", "ABBBA",
- "ABBBB", "BAAAA", "BAAAB", "BAABA", "BAABB",
- "BABAA", "BABAB", "BABBA", "BABBB", "BBAAA",
- "BBAAB", "BBBAA"
- };
- char get_char(const char *code)
- {
- int i;
- for (i = 0; i < 26; ++i)
- {
- if (strcmp(codes[i], code) == 0) return 97 + i;
- }
- }
- int main()
- {
- fin>>C;
- fin>>mess;
- if(C==1)
- {
- for(int i=0; mess[i]; i++)
- fout<<codes[mess[i]-'A'];
- }
- else
- {
- int j=0, i=0;
- while(mess[i])
- {
- for(int j=0; j<5; j++)
- ha[j]=mess[i++];
- ha[5]='\0';
- fout<<((char)toupper(get_char(ha)));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement