codeforce 599B Spongebob and Joke
一道水题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的更多相关文章
- Codeforces 599B. Spongebob and Joke 模拟
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- CodeForces 599B Spongebob and Joke
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- 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 ...
- CF-599B - Spongebob and Joke
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #332 (Div. 二) B. Spongebob and Joke
Description While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. ...
- CF599B Spongebob and Joke
思路: 模拟,注意特判. 实现: #include <iostream> #include <cstdio> using namespace std; ], x[], y[], ...
随机推荐
- Java面向对象的三大特性 多态
多态 对象的多种形态 继承是实现多态的基础 1,引用多态 父类的引用可以指向本类的对象 父类的引用可以指向子类的对象 2,方法多态 创建本类对象时,调用的方法为本类方法 创建子 ...
- Machine Learning-KNN
思路:如果一个样本在特征空间中的k个最相近的样本中大多数属于某个类别,则该样本也属于该类别: 这段话中涉及到KNN的三要素:K.距离度量.决策规则 K:KNN的算法的结果很大程度取决于K值的选择: I ...
- Spark SQL 读到的记录数与 hive 读到的不一致
问题:我用 sqoop 把 Mysql 中的数据导入到 hive,使用了--delete-target-dir --hive-import --hive-overwrite 等参数,执行了两次. my ...
- 图解 SSH上传安装tomcat
安装步骤: 1.SSH上传压缩包 2.[root@localhost soft]# tar -zxvf apache-tomcat-7.0.61.tar.gz //解压安装 解压结果 3.[r ...
- 洛谷P3380 【模板】二逼平衡树(树套树)(线段树+树状数组)
P3380 [模板]二逼平衡树(树套树) 题目描述 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作: 查询k在区间内的排名 查询区间内排名为k的值 修改某一位值上的数 ...
- 洛谷P5048 [Ynoi2019模拟赛]Yuno loves sqrt technology III(分块)
传送门 众所周知lxl是个毒瘤,Ynoi道道都是神仙题 用蒲公英那个分块的方法做结果两天没卡过去→_→ 首先我们分块,预处理块与块之间的答案,然后每次询问的时候拆成整块和两边剩下的元素 整块的答案很简 ...
- HQuorumPeer和QuorumPeerMain进程的区别
HBase是列式数据库,既可以单机也可以集群的方式搭建,以集群的方式搭建一般建立在HDFS之上. 分布式HBase启动说明:首先启动hadoop,然后问题就来了:zookeeper和hbase的启动顺 ...
- 使用combobox下拉列表框实现省 市 县 的三级联动
package com.hanqi.entity; //地区 public class Region { //地区id private String regionID; //地区名称 private ...
- jmeter beanshell Typed variable declaration : Object constructor错误
从数据库取值和响应值做比较,使用beanshell如下: import org.json.JSONArray; import org.json.JSONObject; res_str = prev.g ...
- 迷你迅雷+SqlServer2008r2下载
迷你迅雷下载 http://down.sandai.net/mini/MiniThunderInstaller3.1.1.58.exe SqlServer 2008r2下载 ed2k://|file| ...