Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int a[100001];
- int ff[100001];
- int main()
- {
- freopen("input.txt", "r", stdin);
- ios::sync_with_stdio(false); cin.tie(0);
- int n, m;
- cin >> n >> m;
- for (int i = 1; i <= n; i++)
- {
- int f;
- cin >> f;
- ff[f] = ff[f] == 0 ? i : -1;
- }
- bool ambiguity = false;
- for (int i = 1; i <= m; i++)
- {
- int b;
- cin >> b;
- if (ff[b] > 0) a[i] = ff[b];
- else if (ff[b] == -1) ambiguity = true;
- else
- {
- cout << "Impossible";
- return 0;
- }
- }
- if (ambiguity)
- {
- cout << "Ambiguity";
- return 0;
- }
- cout << "Possible\n";
- for (int i = 1; i <= m; i++)
- cout << a[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment