CodeForces 599B Spongebob and Joke

简单题。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int maxn=100000+10;
int n,m;
int b[maxn],f[maxn];

int cnt[maxn];

int main()
{
    scanf("%d%d",&n,&m);
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&f[i]);
        cnt[f[i]]++;
    }
    for(int i=1;i<=m;i++) scanf("%d",&b[i]);

    bool fail=0;
    for(int i=1;i<=m;i++) if(cnt[b[i]]==0) fail=1;

    if(fail==1) printf("Impossible\n");
    else
    {
        fail=0;
        for(int i=1;i<=m;i++) if(cnt[b[i]]>1) fail=1;
        if(fail) printf("Ambiguity\n");
        else{
            printf("Possible\n");
            memset(cnt,0,sizeof cnt);
            for(int i=1;i<=n;i++) cnt[f[i]]=i;
            for(int i=1;i<=m;i++) printf("%d ",cnt[b[i]]);
            printf("\n");
        }
    }
    return 0;
}
时间: 2024-08-05 19:43:41

CodeForces 599B Spongebob and Joke的相关文章

[cf 599B] Spongebob and Joke

判断题,有点绕,注意在答案不唯一时的判断条件要依据B数组判断 #include <iostream> #include <algorithm> #include <map> using namespace std; int b[110000],f[110000]; map <int,int> Map,A; int main() { int n,i,m; cin >> n >> m; for(i=1;i<=n;++i) { cin

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+10; int f[maxn], b[maxn], a[maxn]; int g[maxn]; bool mul[maxn]; //#define L

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 on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1

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

Description While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not

[Codeforces599B] Spongebob and Joke (模拟)

题目概述: While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not neces

CodeForces 599D Spongebob and Squares

先推导出公式x*(x+1)(3*y-x+1)=6*n,然后枚举求解. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<algorithm> using namespace std; vector<long long >ansx,ansy; long long n; int main() { while(~scanf("%

Codeforces Round #332 (Div. 2)

好菜,不说话了,说题. A - Patrick and Shopping 从一个点出发,要经过其他两个点,然后回到原地,求最小时间花费.只有四种情况,从中选一个最小的就行了. #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <math.h> #include <algorithm> using namespace

2017-5-18-Train: Codeforces Round #332 (Div. 2)

A. Patrick and Shopping(模拟题) Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first sh

Codeforces Amusing Joke 题解

So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name i