Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- #include<map>
- using namespace std;
- vector<int> Finish_sost ;
- map<char, int> char_ind;
- int curr = 0;
- int ref_sost[3][5] =
- {
- 0, 0, -1 ,2, -1,
- -1, -1, 2, -1, 1,
- -1, -1, -1, -1, -1,
- };
- //row - h=0,e=1..d=7 // collom - sost
- void init()
- {
- char_ind['m'] = 0;
- char_ind['k'] = 1;
- char_ind['c'] = 2;
- char_ind['b'] = 3;
- char_ind['z'] = 4;
- Finish_sost.push_back(1);
- }
- bool move(char ch)
- {
- if (char_ind.count(ch) && ref_sost[curr][char_ind[ch]] != -1)
- {
- curr = ref_sost[curr][char_ind[ch]];
- return true;
- }
- else
- return false;
- }
- int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- init();
- char ch = getchar();
- while (ch != EOF)
- {
- if (move(ch))
- ch = getchar();
- else
- {
- cout << "No";
- return 0;
- }
- }
- if (find(Finish_sost.begin(), Finish_sost.end(), curr) != Finish_sost.end())
- cout << "Yes";
- else
- cout << "No";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement