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[], ...
随机推荐
- 「学习笔记」Fast Fourier Transform
前言 快速傅里叶变换(\(\text{Fast Fourier Transform,FFT}\) )是一种能在\(O(n \log n)\)的时间内完成多项式乘法的算法,在\(OI\)中的应用很多,是 ...
- 定时器详解和应用、js加载阻塞、css加载阻塞
1.setTimeout().setInterval()详解和应用 1.1 详解: setTimeout.setInterval执行时机 1.2 存在问题: setInterval重复定时器可能存在的 ...
- Spark RDD(Resilient Distributed Dataset)
基于数据集的处理:从物理存储上加载数据,然后操作数据,然后写入物理存储设备.比如Hadoop的MapReduce. 缺点:1.不适合大量的迭代 2. 交互式查询 3. 不能复用曾经的 ...
- Java快速向数据库中插入大量数据 比如10万条以上
String sql = "insert into table *****"; //必须要有这句,要不然效果不明显 con.setAutoCommit(false); ps = c ...
- thinkphp5.1composer引入第三方类库使用注意
下面以引入phpspider为例子: composer引入: composer require owner888/phpspider 这时在vender目录下会多出一个owner888目录,里面就有我 ...
- win下rabbitmq的安装
安装erlang 10.4 和 rabbitmq 3.7.5 然后关闭rabbitmq服务 然后设置 erlang和rabbitmq的环境变量 ERLANG_HOME=erlang安装目录 RABBI ...
- java——集合、泛型、ArrayList、LinkedList、foreach循环、模拟ktv点歌系统
集合:一系列特殊的类,这些类可以存储任意类型的对象,长度可变,集合类都在java.util包中. 但是集合记不住对象的类型,当把对象从集合中取出时这个对象的编译类型就变成了Object类型.这样在取元 ...
- ubuntu apache2配置多站点
ubuntu下使用sudo apt-get install apache2方法安装时,配置文件主要在/etc/apache2/目录下.主要有: apache2.conf : 主配置文件,会通过incl ...
- C - Watchmen
题目链接:https://vjudge.net/contest/237394#problem/C Watchmen are in a danger and Doctor Manhattan toget ...
- list map set常用方法之list
list 常用方法: 默认添加:list.add(e); 指定下标添加(添加后下标后的元素向后挪一位):list.add(index,e); 获得集合内元素个数:list.size(); 返回是否删除 ...