思路:

模拟,注意特判。

实现:

  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. int pos[], x[], y[], b[], n, m, tmp;
  6. int main()
  7. {
  8. cin >> n >> m;
  9. for (int i = ; i <= n; i++)
  10. {
  11. scanf("%d", &tmp);
  12. x[tmp]++;
  13. pos[tmp] = i;
  14. }
  15. for (int i = ; i <= m; i++)
  16. {
  17. scanf("%d", &b[i]);
  18. y[b[i]]++;
  19. }
  20. bool f1 = true, f2 = true;
  21. for (int i = ; i <= n; i++)
  22. {
  23. if (y[i] && !x[i])
  24. {
  25. f1 = false;
  26. break;
  27. }
  28. if (x[i] > && y[i])
  29. {
  30. f2 = false;
  31. }
  32. }
  33. if (!f1)
  34. cout << "Impossible" << endl;
  35. else if (!f2)
  36. cout << "Ambiguity" << endl;
  37. else
  38. {
  39. cout << "Possible" << endl;
  40. for (int i = ; i <= m; i++)
  41. {
  42. printf("%d ", pos[b[i]]);
  43. }
  44. puts("");
  45. }
  46. return ;
  47. }

CF599B Spongebob and Joke的更多相关文章

  1. CF-599B - Spongebob and Joke

    B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. 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 ...

  3. 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 ...

  4. Codeforces 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     While Patrick was gone shopping, Spongebob decided to play a little trick ...

  7. Codeforces Round #332 (Div. 二) B. Spongebob and Joke

    Description While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. ...

  8. codeforce 599B Spongebob and Joke

    一道水题WA那么多发,也是醉了.f看成函数的话,其实就是判断一下反函数存不存在. 坑点,只能在定义域内判断,也就是只判断b[i].没扫一遍前不能确定Impossible. #include<bi ...

  9. CodeForces 599B Spongebob and Joke

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. java重载中的基本类型的自动类型转换

    当传递到函数的参数的数据类型表示的范围小于函数形参的参数类型遵循如下原则 : char类型比较特殊, 直接转换为int:  char ->int ->long->float-> ...

  2. udhcp源码详解(四) 之租赁IP的管理

    Server端对于租赁出去的IP的管理是基于结构体dhcpOfferedAddr的,该结构体的定义是在leases.c文件里:(结构体的成员介绍说明见详解之数据结构) 1: struct dhcpOf ...

  3. mysql 中 unix_timestamp和from_unixtime 时间戳函数

    1.unix_timestamp 将时间转化为时间戳.(date 类型数据转换成 timestamp 形式整数) 没传时间参数则取当前时间的时间戳 mysql> select unix_time ...

  4. ffmpeg转码本地文件(一)

    ffmpeg转码本地文件(一) 实现目标:输入本地文件.实现本地文件转码,里面包括mux层转码,codec层转码,视频格式转换,音频重採样等功能,功能点请看凝视.注意:凝视非常重要. #ifndef ...

  5. select case when if

    select case when if 的一些用法 - 马丁传奇 - 博客园 https://www.cnblogs.com/martinzhang/p/3220595.html Write a SQ ...

  6. Android4.4.2系统添加自定义按键【转】

    本文转载自:http://developer.t-firefly.com/thread-251-1-1.html 网上存在一些关于Android系统添加自定义按键的文章,但大多针对Android2.3 ...

  7. lmbench andlmbench 移植测试

    /*********************************************************************** * lmbench andlmbench 移植测试 * ...

  8. C# ListView 列宽调整 刷新

    /*********************************************************************** * C# ListView 列宽调整 刷新 * 说明: ...

  9. [转]python_常用断言assert

    原文地址:http://www.jianshu.com/p/eea0b0e432da python自动化测试中寻找元素并进行操作,如果在元素好找的情况下,相信大家都可以较熟练地编写用例脚本了,但光进行 ...

  10. JavaScript-Tool:CKFinder

    ylbtech-JavaScript-Tool:CKFinder 1.返回顶部 CKFinder是一个强大而易于使用的Web浏览器的Ajax文件管理器. 其简单的界面使得它直观,快速学习的各类用户,从 ...