Guest User

codeforces.com/contest/599/problem/B

a guest
Nov 20th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int a[100001];
  7. int ff[100001];
  8.  
  9. int main()
  10. {
  11.     freopen("input.txt", "r", stdin);
  12.  
  13.     ios::sync_with_stdio(false); cin.tie(0);
  14.  
  15.     int n, m;
  16.     cin >> n >> m;
  17.  
  18.     for (int i = 1; i <= n; i++)
  19.     {
  20.         int f;
  21.         cin >> f;
  22.  
  23.         ff[f] = ff[f] == 0 ? i : -1;
  24.     }
  25.  
  26.     bool ambiguity = false;
  27.     for (int i = 1; i <= m; i++)
  28.     {
  29.         int b;
  30.         cin >> b;
  31.  
  32.         if (ff[b] > 0) a[i] = ff[b];
  33.         else if (ff[b] == -1) ambiguity = true;
  34.         else
  35.         {
  36.             cout << "Impossible";
  37.             return 0;
  38.         }
  39.     }
  40.  
  41.     if (ambiguity)
  42.     {
  43.         cout << "Ambiguity";
  44.         return 0;
  45.     }
  46.  
  47.     cout << "Possible\n";
  48.     for (int i = 1; i <= m; i++)
  49.         cout << a[i] << " ";
  50. }
Advertisement
Add Comment
Please, Sign In to add comment