Codeforces #332 B. Spongebob and Joke (思路)

原创 2015年11月21日 03:15:37

题意:

nf,mb,fai=b[i],m
Ambiguity,Impossible,Possible

分析:

f,,Ambiguous,1
,Impossible
AmbiguityAmbiguous,,思维不够缜密啊!!!

数据:

3 1
2 1 1
2

ans:
Possible
1

代码:

//
//  Created by TaoSama on 2015-11-21
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, m, f[N], a[N], b[N], wh[N];

int main() {
#ifdef LOCAL
    freopen("C:\\Users\\TaoSama\\Desktop\\in.txt", "r", stdin);
//  freopen("C:\\Users\\TaoSama\\Desktop\\out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    while(scanf("%d%d", &n, &m) == 2) {
        memset(wh, 0, sizeof wh);
        memset(a, 0, sizeof a);
        for(int i = 1; i <= n; ++i) {
            scanf("%d", f + i);
            if(wh[f[i]]) wh[f[i]] = -1;
            else wh[f[i]] = i;
        }

        bool Ambiguity = false, Impossible = false;
        for(int i = 1; i <= m; ++i) {
            scanf("%d", b + i);
            if(!wh[b[i]]) Impossible = true;
            else if(wh[b[i]] == -1) Ambiguity = true;
            a[i] = wh[b[i]];
        }
        if(Impossible) puts("Impossible");
        else if(Ambiguity) puts("Ambiguity");
        else {
            puts("Possible");
            for(int i = 1; i <= m; ++i)
                printf("%d%c", a[i], " \n"[i == m]);
        }
    }
    return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

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

codeforces ACM 模拟

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

Codeforces Round #332 (Div. 2) C. Spongebob and Joke Vector

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

【Codeforces Round 332 (Div 2)B】【扭转题意 位置映射】Spongebob and Joke 给b[]中的每个数找f[]中的位置

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

Codeforces 599B: Spongebob and Joke(技巧,规律)

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

codeforces 599B Spongebob and Joke

B. Spongebob and Joketime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard ...

Codeforces 599 B Spongebob and Joke

传送门: http://codeforces.com/problemset/problem/599/B 题意: 给出序列f[i]和f[a[i]],要求还原序列a[i]不就是记录一下ans[f[i...

【Codeforces Round 332 (Div 2)D】【数学 公式推导】Spongebob and Squares 正方形数量恰好为x个的所有大矩形

D. Spongebob and Squares time limit per test 2 seconds memory limit per test 256 megabyt...

Codeforces Round #332 (Div. 2) D. Spongebob and Squares

Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked y...

Codeforces Round #332 (Div. 2) D. Spongebob and Squares详解

Codeforces Round #332 (Div. 2) D. Spongebob and Squares
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)