Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. #include<map>
  5. using namespace std;
  6. vector<int> Finish_sost  ;
  7. map<char, int> char_ind;
  8. int curr = 0;
  9. int ref_sost[3][5] =
  10. {
  11.     0, 0, -1 ,2,   -1,
  12.    -1, -1, 2, -1,   1,
  13.    -1, -1, -1, -1, -1,
  14.  
  15.  
  16. };
  17. //row - h=0,e=1..d=7 // collom - sost
  18. void init()
  19. {
  20.         char_ind['m'] = 0;
  21.         char_ind['k'] = 1;
  22.         char_ind['c'] = 2;
  23.         char_ind['b'] = 3;
  24.         char_ind['z'] = 4;
  25.        
  26.  Finish_sost.push_back(1);
  27. }
  28. bool move(char ch)
  29. {
  30.         if (char_ind.count(ch) && ref_sost[curr][char_ind[ch]] != -1)
  31.         {
  32.                 curr = ref_sost[curr][char_ind[ch]];
  33.                 return true;
  34.         }
  35.         else
  36.                 return false;
  37. }
  38. int main() {
  39.         freopen("input.txt", "r", stdin);
  40.         freopen("output.txt", "w", stdout);
  41.         init();
  42.         char ch = getchar();
  43.         while (ch != EOF)
  44.         {
  45.                 if (move(ch))
  46.                         ch = getchar();
  47.                 else
  48.                 {
  49.                         cout << "No";
  50.                         return 0;
  51.                 }
  52.         }
  53.         if (find(Finish_sost.begin(), Finish_sost.end(), curr) != Finish_sost.end())
  54.                 cout << "Yes";
  55.         else
  56.                 cout << "No";
  57.         return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement