[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 >> f[i];
        if(!Map[f[i]])Map[f[i]]=i;
        else
        {
            A[f[i]]=true;
        }
    }
    for(i=1;i<=m;++i)
    {
        cin >> b[i];
        if(!Map[b[i]])
        {
            cout << "Impossible" << endl;
            return 0;
        }
    }

    for(i=1;i<=m;++i)
    {
        if(A[b[i]])
        {
            cout << "Ambiguity" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    for(i=1;i<=m;++i)
    {
        cout << Map[b[i]] << ‘ ‘;
    }
    cout << endl;
    return 0;
}
时间: 2024-10-18 16:40:09

[cf 599B] Spongebob and Joke的相关文章

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,

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

[cf 599D] Spongebob and Squares

据题意: k=Σ(i=0 to n-1)(n-i)*(m-i) k=n2m -(n+m)Σ(i)+Σ(i2) 展开化简 m=(6k-n+n3)/(3n2+3n) 枚举n,验证整除,只做n<=m,其余反过来输出即可 #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath

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

微信 {&quot;errcode&quot;:40029,&quot;errmsg&quot;:&quot;invalid code, hints: [ req_id: Cf.y.a0389s108 ]&quot;}

{"errcode":40029,"errmsg":"invalid code, hints: [ req_id: Cf.y.a0389s108 ]"} 问题:微信网页授权后,获取到 openid 了,一刷新又没了 微信网页授权获取到的 code 只能使用一次(5分钟内有效),使用一次后,马上失效. 页面授权跳转成功,根据 code 也换取到 openid 了. 此时刷新页面,并不会再次进行授权,而是直接刷新了一下上一次授权跳转后的链接,带的还是