思路:

模拟,注意特判。

实现:

 #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. 有oracle 10g,但没有安装arcgis,又想使用空间数据库的解决方案

    我在一台虚拟机中部署系统进行测试,配置如下: OS:WIN2008 R2 SP1 X64 DB: oracle 12c 结果系统报错,查找原因,原来是oracle里还不支持arcgis的一些所谓的空间 ...

  2. Why was 80 Chosen as the Default HTTP Port and 443 as the Default HTTPS Port?

    https://www.howtogeek.com/233383/why-was-80-chosen-as-the-default-http-port-and-443-as-the-default-h ...

  3. ubuntu切换中英文通用方法,ubuntu中文语言

    1:点击桌面右上角的齿轮,选择“system settings”进入系统设置界面

  4. YTU 2901: G-险恶逃生II

    2901: G-险恶逃生II 时间限制: 1 Sec  内存限制: 128 MB 提交: 44  解决: 14 题目描述     SOS!!!koha is trapped in the danger ...

  5. ACTION中获得数据的几种方式

    1.第一种是通过公司封装的方法. 2.第二种:是通过IF方法判断 3.第三种是通过:set/get获得

  6. I.MX6 wpa_applicant 开启 debug 输出

    /*********************************************************************** * I.MX6 wpa_applicant 开启 de ...

  7. Linux网络协议栈(三)——网络设备(1)

    网络设备(network device)是内核对网络适配器(硬件)的抽象与封装,并为各个协议实例提供统一的接口,它是硬件与内核的接口,它有两个特征:(1)    作为基于硬件的网络适配器与基于软件的协 ...

  8. [学习笔记]dsu on a tree(如何远离线段树合并)

    https://www.zybuluo.com/ysner/note/1318613 背景 这玩意来源于一种有局限性的算法. 有一种广为人知的,树上离线维护子树信息的做法. (可以参照luogu360 ...

  9. sqlserver2008Mail

    use msdb  GO    DROP PROC MailTim  GO    CREATE PROC MailTim  @Subject NVARCHAR(100),@Body NVARCHAR( ...

  10. Gerrit代码Review实战

    代码审核(Code Review)是软件研发质量保障机制中非常重要的一环,但在实际项目执行过程中,却因为种种原因被Delay甚至是忽略.在实践中,给大家推荐一款免费.开放源代码的代码审查软件Gerri ...