一道水题WA那么多发,也是醉了。f看成函数的话,其实就是判断一下反函数存不存在。

坑点,只能在定义域内判断,也就是只判断b[i]。没扫一遍前不能确定Impossible。

#include<bits/stdc++.h>
using namespace std; typedef long long ll; const int maxn = 1e5+; int f[maxn], b[maxn], a[maxn];
int g[maxn];
bool mul[maxn]; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int n, m; scanf("%d%d",&n,&m);
bool Abm = false;
for(int i = ; i <= n; i++){
scanf("%d", f+i);
if(g[f[i]]) mul[f[i]] = true;
g[f[i]] = i;
}
for(int i = ; i <= m; i++){
scanf("%d", b+i);
}
bool Imp = false;
for(int i = ; i <= m; i++){
if(!g[b[i]]) {
Imp = true; break;
}
if(mul[b[i]]){
Abm = true;
}
a[i] = g[b[i]];
}
if(Imp) puts("Impossible");
else {
if(Abm) puts("Ambiguity");
else {
puts("Possible");
for(int i = ; i <= m; i++){
printf("%d%c", a[i], i != m? ' ': '\n');
}
}
}
return ;
}

codeforce 599B Spongebob and Joke的更多相关文章

  1. Codeforces 599B. Spongebob and Joke 模拟

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

  2. CodeForces 599B Spongebob and Joke

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

  3. 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 ...

  4. CF-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 time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. 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 ...

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

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

  9. CF599B Spongebob and Joke

    思路: 模拟,注意特判. 实现: #include <iostream> #include <cstdio> using namespace std; ], x[], y[], ...

随机推荐

  1. 使用Realsense D400 camera系列跑rgbdslamv2

    Ubuntu16.04,kinetic 在之前写的博文<如何使用ROS查找rgbdslam代码包框架的输入>中提到,一开始不知道整体框架,只用感性认识去跑rgbdslamv2的包,是一个天 ...

  2. 图解linux安装hadoop

    安装步骤: 一.准备工作 1.解压文件 [root@localhost soft]# tar -zxvf hadoop-2.4.1.tar.gz 2.改名: [root@localhost soft] ...

  3. openstack RPC通信

    openstack RPC通信 OpenStack 的主要组件有 Nova.Cinder.Neutron.Glance 等,分别负责云平台的计算.存储.网络资源管理.openstack 各组件之间是通 ...

  4. Google Guetzli是如何压缩图片的?

    你可能已经知道,现在网页文件的平均大小比Doom游戏的安装文件还还大. 文件变大的原因之一是图片的增加,并且还需要支持更高的分辨率. Google来拯救了 Google刚刚发布了一种新的JPEG压缩算 ...

  5. python 3.7 生成数据库文档

    开发阶段数据库总是有变动,开发人员需要维护文档给相关人员使用,故编写一个脚本自动生成数据库文档 生成的excel如下 import cx_Oracle import os from openpyxl ...

  6. BZOJ 4919: [Lydsy1706月赛]大根堆 启发式合并

    我不会告诉你这是线段树合并的好题的... 好吧我们可以搞一个multiset在dfs时求出LIS(自带二分+排序)进行启发式合并,轻松加愉悦... #include<cstdio> #in ...

  7. PHP 获取acm近期比赛

    <?php // author: Moore Jiang. ini_set('display_errors',1); //错误信息 ini_set('display_startup_errors ...

  8. jdb应用

    场景: 外网可以登录远程主机,但是因为安全限制,不能在外网直接访问docker应用的端口,因此不能远程调试.远程主机shell内部可以连接docker应用,也没有图形界面,没有log,考虑使用原始的j ...

  9. 【ACM】组合数 - 全排列

    组合数 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 找出从自然数1.2.... .n(0<n<10)中任取r(0<r<=n)个数的所有组合 ...

  10. 强制更新客户端Silverlight XAP 文件

    在发布小程序更新的时候访问的总是原来的程序,猜想应该是缓存的原因.在网上查找方法 <div id="silverlightControlHost"> <objec ...