codeforce 599B Spongebob and Joke
2024-08-22 22:45:32
一道水题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 ;
}
最新文章
- jquery1.9以上版本如何使用toggle函数
- linux两台服务器之间文件/文件夹拷贝
- WKWebView
- dojo Provider(script、xhr、iframe)源码解析
- java编写冒泡排序
- Bootstrap文本对齐风格
- AspNetPager 自定义html
- On-board diagnostics connector SAE J1962
- Java数据结构之树和二叉树(2)
- “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常。
- CriticalFinalizerObject的作用
- 文件上传插件Uploadify在Struts2中的应用,完整详细实例
- WEB 移动网站 手机点击 打电话 发短信
- Linux中使用京东代码库JDCode创建私有Git仓库
- Android 访问地址
- React项目中跨域问题的解决方案
- Notepad++ 配置 Sql PoorMan 插件
- Day 4-2 random模块
- python 如何把小数变成百分数格式
- meterpreter命令大全
热门文章
- SAS笔记(5) FLAG和计数器
- java部分基础知识整理----百度脑图版
- Scrapy框架初探
- 《权限系列shiro+cas》---封装公共验证模块
- 误删重要文件怎么办?学会Linux 救援模式再也不担心
- express-http-proxy 的基础使用
- 73th LeetCode Weekly Contest Escape The Ghosts
- CentOS 安装最新的 RabbitMQ 3.7.8
- QueueUtil
- spark_运行spark-shell报错_javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database.