思路:

模拟,注意特判。

实现:

 #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. 10.2.0.1.1 grid control的启动和关闭

    一.Stopping Grid Control and All Its Components 1.停止OMS服务 [oracle@ocm2 oms10g]$ cd /u01/app/oracle/Or ...

  2. 给GridView设置行高

    近期在工作中遇到了这样一个问题,使用一个GridView展示数据,item中仅仅是一个TextView,可是里面显示的文字多少不固定多少,必须所有展示出来. 遇到的问题: 1.把item中的宽和高设置 ...

  3. 十分简洁的手机浏览器 lydiabox

    没有地址栏,没有工具栏.web app无需下载.无需安装.无需更新,加入即用:再也不用记住网址.更不用输入网址--一款这样极简极方便的浏览器,你想要吗? 我们做了一个十分简洁的手机浏览器,这个浏览器也 ...

  4. 2016/05/16 UEditor 文本编辑器 使用教程与使用方法

    第一:百度UEditor编辑器的官方下载地址 ueditor 官方地址:http://ueditor.baidu.com/website/index.html 开发文档地址:http://uedito ...

  5. VS2010调用外部webservice

    vs2010怎么调用web服务webservice方法,以vs2010为例.Vs的各个版本的此项功能操作基本一致. 工具/原料 vs2010 在“服务引用设置”对话框中,单击“添加 Web 引用”. ...

  6. GET 与 POST 的理解

    1 HTTP请求      超文本传输协议(HTTP)的设计目的是保证客户机与服务器之间的通信.      HTTP 的工作方式是客户机与服务器之间的请求-应答协议.      比如,客户端(浏览器) ...

  7. h5ai目录列表优化

    h5ai是HTTP Web服务器的现代文件索引器,专注于您的文件.目录以有吸引力的方式显示,浏览它们通过不同的视图,面包屑和树状概述增强.最初,h5ai是HTML5 Apache Index的缩写,但 ...

  8. YTU 1098: The 3n + 1 problem

    1098: The 3n + 1 problem 时间限制: 1 Sec  内存限制: 64 MB 提交: 368  解决: 148 题目描述 Consider the following algor ...

  9. YTU 1007: Redraiment猜想

    1007: Redraiment猜想 时间限制: 1000 Sec  内存限制: 10 MB 提交: 83  解决: 23 题目描述 redraiment在家极度无聊,于是找了张纸开始统计素数的个数. ...

  10. 简单的处理git add ,git commit,git push 脚本

    创建脚本lazygit.sh #!/bin/bash # 一次性处理git提交 #branch_name=`git symbolic-ref --short -q HEAD` branch_name= ...