Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n, m, input;
- vector<int> platformy;
- queue<int> wej;
- queue<int> wyj;
- cin >> n >> m;
- for(int i = 0; i < m; i++)
- platformy.push_back(-1);
- for(int i = 0; i < n; i++)
- {
- cin >> input;
- wej.push(input);
- }
- for(int i = 0; i < n; i++)
- {
- cin >> input;
- wyj.push(input);
- }
- int var;
- while(!wej.empty())
- {
- var = wej.front();
- wej.pop();
- if(var == wyj.front())
- {
- wyj.pop();
- while(true)
- {
- if(find(platformy.begin(), platformy.end(), wyj.front()) != platformy.end())
- {
- wyj.pop();
- platformy[(*find(platformy.begin(), platformy.end(), wyj.front()))] = -1;
- }
- else
- break;
- }
- continue;
- }
- if(find(platformy.begin(), platformy.end(), -1) == platformy.end())
- {
- cout << "NIE";
- return 0;
- }
- else
- {
- platformy[*find(platformy.begin(), platformy.end(), -1)] = var;
- }
- }
- cout << "TAK";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement