[cf 599B] Spongebob and Joke

判断题,有点绕,注意在答案不唯一时的判断条件要依据B数组判断

#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int    b[110000],f[110000];
map <int,int>    Map,A;

int main()
{
    int    n,i,m;
    cin >> n >> m;
    for(i=1;i<=n;++i)
    {
        cin >> f[i];
        if(!Map[f[i]])Map[f[i]]=i;
        else    
        {
            A[f[i]]=true;
        }
    }
    for(i=1;i<=m;++i)
    {
        cin >> b[i];
        if(!Map[b[i]])
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }

    for(i=1;i<=m;++i)
    {
        if(A[b[i]])
        {
            cout << "Ambiguity" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    for(i=1;i<=m;++i)
    {
        cout << Map[b[i]] << ' ';
    }
    cout << endl;
    return 0;
}

 

posted @ 2015-11-21 17:58  Gster  阅读(212)  评论(0编辑  收藏  举报