一道水题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. Codeforces Round#522 Div2E(思维,背包,组合数学)

    #include<bits/stdc++.h>using namespace std;int a[107];int b[10007][107];int c[107][107];int ma ...

  2. Unity 2018中的图形渲染

    https://mp.weixin.qq.com/s?__biz=MzU5MjQ1NTEwOA==&mid=2247490249&idx=1&sn=d86083e33d9884 ...

  3. ffmpeg转码多路输出(二)

    ffmpeg转码多路输出(二)本程序支持一路输入多路输出,可根据map配置自行添加,第1路为纯拷贝,其他2路经过编解码,格式转换缩放和重采样,纯拷贝方面不同格式适应方面还没做全,以后补充.本程序适合多 ...

  4. Jmeter-返回值乱码处理

    Jmeter安装目录/bin/jmeter.properties中sampleresult.default.encoding默认为ISO-8859-1,将参数修改为 sampleresult.defa ...

  5. 洛谷P2846 光开关Light Switching

    题目描述 灯是由高科技--外星人鼠标操控的.你只要左击两个灯所连的鼠标, 这两个灯,以及之间的灯都会由暗变亮,或由亮变暗.右击两个灯所连的鼠 标,你就可以知道这两个灯,以及之间的灯有多少灯是亮的.起初 ...

  6. 文件拷贝io nio比较

    import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedRead ...

  7. 有效使用Mock编写java单元测试

    Java单元测试对于开发人员质量保证至关重要,尤其当面对一团乱码的遗留代码时,没有高覆盖率的单元测试做保障,没人敢轻易对代码进行重构.然而单元测试的编写也不是一件容易的事情,除非使用TDD方式,否则编 ...

  8. linux 向文本指定位置写入内容

    sed -i "37 r a.txt" test.txt ====== 向test.txt 的第37行后,也就是38行后写入a.txt的内容 sed -i "38i aa ...

  9. Java集合——List集合

    1.集合框架的作用 在实际开发中,我们经常会对一组相同类型的数据进行统一管理操作.到目前为止,我们可以使用数组结构,链表结构,二叉树结构来实现. 数组的最大问题在于数组中的元素个数是固定的,要实现动态 ...

  10. Java BIO

    目录 BIO 字节流 OutputStream InputStream 字符流 Reader Writer 转换流 InputStreamReader OutputStreamWriter BIO I ...