思路:

模拟,注意特判。

实现:

 #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. Android5.0(lollipop)新特性介绍(一)

    今年6月的Google I/O大会上.Android L的初次见面我相信让会让非常多android粉丝有些小激动和小期待.当然作为开发人员的我来说,激动不言而喻,毕竟这是自08年以来改变最大的一个版本 ...

  2. android通过adb wireless的使用

    转自:http://www.cnblogs.com/Androider123/p/3848415.html?utm_source=tuicool 开发android程序,总是需要插拔插拔的,usb口都 ...

  3. 当你使用LINQ做底层时,最好设计一个工厂,不要把LINQ的动作暴露给业务层

    1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.Text; 5: ...

  4. Tomcat9无法启动

    闲来无事,重新学习一下Java, 去Tomcat官网下载Tomcat,各种版本,7-8-9,果断下载最新的9,解压后,无需安装,到bin文件夹下启动, 结果总是一闪而过,百度: 1.查看8080是否占 ...

  5. make eval builtin function

    1 eval的返回值是空字符串,因此它可以用于Makefile的任何位置而不引起错误 2 eval函数的作用效果 生成Makefile的动态部分,即eval用于增加Makefile的构成部分. 也就是 ...

  6. Pulse-code modulation

    脉冲编码调制(Pulse Code Modulation,PCM),由A.里弗斯于1937年提出的,这一概念为数字通信奠定了基础,60年代它开始应用于市内电话网以扩充容量,使已有音频电缆的大部分芯线的 ...

  7. cgi fastcgi wsgi nginx python Dispatching TurboGears Python via FCGI

    https://www.nginx.com/resources/wiki/start/topics/examples/simplepythonfcgi/ 117 2018-06-28 19:56:42 ...

  8. GET和POST 编码和乱码

    1.  什么是URL编码. URL编码是一种浏览器用来打包表单输入的格式,浏览器从表单中获取所有的name和其对应的value,将他们以name/value编码方式作为URL的一部分或者分离的发送到服 ...

  9. 笔试题:求第M个到第N个素数之间全部素数

    题目描写叙述 令Pi表示第i个素数. 现任给两个正整数M <= N <= 10000,请输出PM到PN的全部素数. 输入描写叙述: 输入在一行中给出M和N,其间以空格分隔. 输出描写叙述: ...

  10. mac系统下如何删除银行安全插件

    要分类解决了,一般safair插件都是pkg包安装的 如果:1.制作者够良心,PKG安装包中植入了删除卸载功能,那就好办了,打开当时安装的pkg包,执行删除选项 2.没良心的,装了不好删的,我目前个人 ...