离散题目7

来源:互联网 发布:武汉软件新城怎么样 编辑:程序博客网 时间:2024/05/20 03:47

Problem Description

DaYu在新的学习开始学习新的数学知识,一天DaYu学习集合的时候遇到一个问题,他有一个集合A和A的子集B,他想用一个二进制串表示集合B。

Input

多组输入,每组的第一行有两个数n,m,(0< m < n < 10^5).

第二行输入n个数表示集合A,第三行输入m个数表示集合B,|data_i|< 10^5

Output

输出一个01字符串表示集合B

Example Input

10 51 2 3 4 5 6 7 8 9 101 3 5 7 8

Example Output

1010101100

code:

#include <stdio.h>#include <string.h>int main(){    int a[200010], b[200010];    int n, m, i, x;    while(~scanf("%d%d", &n, &m))    {        memset(b, 0, sizeof(a));        for(i = 0;i<n;i++)        {            scanf("%d", &a[i]);        }        for(i = 0;i<m;i++)        {            scanf("%d", &x);            b[x+100000] = 1;        }        for(i = 0;i<n;i++)        {            printf("%d", b[a[i]+100000]);        }        printf("\n");    }}


原创粉丝点击