一道水题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 ;
}

最新文章

  1. jquery1.9以上版本如何使用toggle函数
  2. linux两台服务器之间文件/文件夹拷贝
  3. WKWebView
  4. dojo Provider(script、xhr、iframe)源码解析
  5. java编写冒泡排序
  6. Bootstrap文本对齐风格
  7. AspNetPager 自定义html
  8. On-board diagnostics connector SAE J1962
  9. Java数据结构之树和二叉树(2)
  10. “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常。
  11. CriticalFinalizerObject的作用
  12. 文件上传插件Uploadify在Struts2中的应用,完整详细实例
  13. WEB 移动网站 手机点击 打电话 发短信
  14. Linux中使用京东代码库JDCode创建私有Git仓库
  15. Android 访问地址
  16. React项目中跨域问题的解决方案
  17. Notepad++ 配置 Sql PoorMan 插件
  18. Day 4-2 random模块
  19. python 如何把小数变成百分数格式
  20. meterpreter命令大全

热门文章

  1. SAS笔记(5) FLAG和计数器
  2. java部分基础知识整理----百度脑图版
  3. Scrapy框架初探
  4. 《权限系列shiro+cas》---封装公共验证模块
  5. 误删重要文件怎么办?学会Linux 救援模式再也不担心
  6. express-http-proxy 的基础使用
  7. 73th LeetCode Weekly Contest Escape The Ghosts
  8. CentOS 安装最新的 RabbitMQ 3.7.8
  9. QueueUtil
  10. spark_运行spark-shell报错_javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database.