思路:

模拟,注意特判。

实现:

 #include <iostream>
#include <cstdio>
using namespace std; int pos[], x[], y[], b[], n, m, tmp;
int main()
{
cin >> n >> m;
for (int i = ; i <= n; i++)
{
scanf("%d", &tmp);
x[tmp]++;
pos[tmp] = i;
}
for (int i = ; i <= m; i++)
{
scanf("%d", &b[i]);
y[b[i]]++;
}
bool f1 = true, f2 = true;
for (int i = ; i <= n; i++)
{
if (y[i] && !x[i])
{
f1 = false;
break;
}
if (x[i] > && y[i])
{
f2 = false;
}
}
if (!f1)
cout << "Impossible" << endl;
else if (!f2)
cout << "Ambiguity" << endl;
else
{
cout << "Possible" << endl;
for (int i = ; i <= m; i++)
{
printf("%d ", pos[b[i]]);
}
puts("");
}
return ;
}

CF599B Spongebob and Joke的更多相关文章

  1. CF-599B - Spongebob and Joke

    B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. Codeforces Round #332 (Div. 2) B. Spongebob and Joke 水题

    B. Spongebob and Joke Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599 ...

  3. Codeforces Round #332 (Div. 2)_B. Spongebob and Joke

    B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. Codeforces 599B. Spongebob and Joke 模拟

    B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. Codeforces Round #332 (Div. 2)B. Spongebob and Joke

    B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #332 (Div. 2) B. Spongebob and Joke 模拟

    B. Spongebob and Joke     While Patrick was gone shopping, Spongebob decided to play a little trick ...

  7. Codeforces Round #332 (Div. 二) B. Spongebob and Joke

    Description While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. ...

  8. codeforce 599B Spongebob and Joke

    一道水题WA那么多发,也是醉了.f看成函数的话,其实就是判断一下反函数存不存在. 坑点,只能在定义域内判断,也就是只判断b[i].没扫一遍前不能确定Impossible. #include<bi ...

  9. CodeForces 599B Spongebob and Joke

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. JavaSE入门学习23:Java面向对象之构造方法

    学了JavaSE面向对象这一部分,也该对构造方法做一个总结了. 一构造方法 在多数情况下,初始化一个对象的终于步骤是去调用这个对象的构造方法. 构造方法负责对象的初始化工作,为 实例变量赋予合适的初始 ...

  2. 适合初学C语言是练习的代码

    作为一个小白,自己学C的时候就想找些代码练练手,就整理了一些. 1.最大公约数和最小公倍数 # include <stdio.h> int main(void) {     int i, ...

  3. Fix "Unable to lock the administration directory (/var/lib/dpkg/)" in Ubuntu

    While using the apt-get command or the relatively new APT package management tool in Ubuntu Linux or ...

  4. 从Script到Code Blocks、Code Behind到MVC、MVP、MVVM(转载)

    http://www.cnblogs.com/indream/p/3602348.html 刚过去的周五(3-14)例行地主持了技术会议,主题正好是<UI层的设计模式——从Script.Code ...

  5. 正则表达式ab?c匹配的字符串是?(B)

    A:abcd B:abc C:abcbc D:aEbc

  6. LIKIE INSTR

    SELECT  url FROM test_url WHERE   FROM_UNIXTIME(create_time,'%Y%m%d %H') < '20171218 00'  AND  no ...

  7. HDU 5056 Boring count(不超过k个字符的子串个数)

    Boring count Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tot ...

  8. Dancing Links 专题总结

    算法详细:Dancing Links博客 1.精确覆盖: ZOJ3209 Treasure Map HUST1017 Exact cover POJ3074 Sudoku 2.可重复覆盖: HDU22 ...

  9. 深入理解JMM(Java内存模型) --(一)

    并发编程模型的分类 在并发编程中,我们需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来交换信息.在命令式编程中,线程之间的通信 ...

  10. UVa 12709 && UVaLive 6650 Falling Ants (水题)

    题意:给定 n 个长方体的长,宽,高,让你求高最大的时候体积最大是多少. 析:排序,用高和体积排序就好. 代码如下: #pragma comment(linker, "/STACK:1024 ...