离散数学之单射

单射


#include<string.h>
#include<stdio.h>
int main()
{
    int n ,i ,j ,x,flag;
    int a[100010],b[100010];
    
    while(scanf("%d", &n)!=EOF)
    {
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        for(i = 0;i < n; i++)
        {
            scanf("%d",&x);
            a[x] = 1;
        }
        for(j = 0;j < n;j++)
        {
            scanf("%d",&x);
            b[x] = 1;
        }
        flag = 0;
        
        for(i = 1;i <= 2 * n;i++)
        {
            scanf("%d", &x);
            
            if(i % 2 != 0)
            {
                if(a[x] == 1)
                {
                    a[x] = 0;
                }
                else flag = 1;
            }
            
            else
            {
                if(b[x] != 1)
                {
                    flag = 1;
                }
            }
        }
        if(flag)
            printf("no\n");
        else printf("yes\n");
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/eider1998/article/details/80085617
今日推荐