Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- ifstream fin("zimeria.in");
- ofstream fout("zimeria.out");
- vector<int> c(30);
- vector<char> ic(30);
- vector<int> cod;
- string s;
- char cc[5];
- int cer, n, ccc = 0;
- char p;
- inline void afis(int cod)
- {
- ccc = 4;
- while (cod)
- {
- cc[ccc] = ic[cod % 100];
- cod /= 100;
- --ccc;
- }
- fout << cc << '\n';
- }
- int main()
- {
- std::ios::sync_with_stdio(false);
- fin >> cer >> n;
- for (int i = 1; i <= 12; ++i)
- {
- fin >> p;
- c[p - 'a'] = i;
- ic[i] = p;
- }
- fin.get();
- cod = vector<int>(n);
- for (int i = 0; i < n; ++i)
- {
- fin >> s;
- for (int j = 0; j < (int)s.size(); ++j)
- cod[i] = cod[i] * 100 + c[s[j] - 'a'];
- }
- sort(cod.begin(), cod.end());
- if (cer == 1)
- {
- int cnt = 1;
- for (int i = 1; i < n; ++i)
- if (cod[i] != cod[i-1])
- ++cnt;
- fout << cnt;
- return 0;
- }
- for (int i = 0; i < n; ++i)
- afis(cod[i]);
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement