Advertisement
iStrzalka

Untitled

Oct 11th, 2017
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n, m, input;
  10. vector<int> platformy;
  11. queue<int> wej;
  12. queue<int> wyj;
  13. cin >> n >> m;
  14. for(int i = 0; i < m; i++)
  15. platformy.push_back(-1);
  16.  
  17. for(int i = 0; i < n; i++)
  18. {
  19. cin >> input;
  20. wej.push(input);
  21. }
  22.  
  23. for(int i = 0; i < n; i++)
  24. {
  25. cin >> input;
  26. wyj.push(input);
  27. }
  28.  
  29. int var;
  30. while(!wej.empty())
  31. {
  32. var = wej.front();
  33. wej.pop();
  34.  
  35. if(var == wyj.front())
  36. {
  37. wyj.pop();
  38. while(true)
  39. {
  40. if(find(platformy.begin(), platformy.end(), wyj.front()) != platformy.end())
  41. {
  42. wyj.pop();
  43. platformy[(*find(platformy.begin(), platformy.end(), wyj.front()))] = -1;
  44. }
  45. else
  46. break;
  47. }
  48. continue;
  49. }
  50.  
  51.  
  52. if(find(platformy.begin(), platformy.end(), -1) == platformy.end())
  53. {
  54. cout << "NIE";
  55. return 0;
  56. }
  57. else
  58. {
  59. platformy[*find(platformy.begin(), platformy.end(), -1)] = var;
  60. }
  61. }
  62. cout << "TAK";
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement