离散题目11
来源:互联网 发布:逛淘宝费流量多少 编辑:程序博客网 时间:2024/05/21 15:03
离散题目11
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
给定一个数学函数写一个程序来确定该函数是否是双射的
Input
多组输入。 第一行输入三个整数n,m,k,分别表示集合a中的元素个数,集合b中的元素个数,集合a到b的映射个数。 第二行输入n个数,代表集合a中的元素。 第三行输入m个数,代表集合b中的元素。接下来k行,每行两个数,代表集合a中的元素x和x在集合b中的像y。
Output
每组数据输出一行,若F为a到b的双射,输出”YES”, 否则输出”NO”。
Example Input
5 5 5
1 2 3 7 8
2 5 6 9 0
1 9
3 2
2 6
7 0
8 5
Example Output
YES
Hint
保证集合a中元素无重复,集合b中元素无重复,映射关系无重复(如:{,})
1<=n,m,k<=1000
1<=a[i], b[i]<=10000
x∈a, y∈b
Think:判断集合A和集合B中的元素是否都出现一次
#include <stdio.h>#include <string.h>int a,b,c,d,e[10010],f[10010],s[10010],ss[10010];int main(){ int n,m,x; while(~scanf("%d%d%d",&n,&m,&x)){ memset(e,0,sizeof(e)); memset(f,0,sizeof(f)); memset(s,0,sizeof(s)); memset(ss,0,sizeof(ss)); for (int i=0;i<n;i++){ scanf("%d",&a); e[a]++; } for (int i=0;i<m;i++){ scanf("%d",&b); f[b]++; } int count=0; for (int i=0;i<x;i++){ scanf("%d%d",&c,&d); if (e[c]>0&&f[d]>0){ s[d]++; ss[c]++; if (ss[c]==1&&s[d]==1){ count++; } } } if(n!=m){ printf("NO\n"); continue; } if (count==m){ printf("YES\n"); } else{ printf("NO\n"); } } return 0;}
阅读全文
0 0
- sdut离散题目11
- 离散题目11
- 离散题目11
- 离散题目11
- 离散题目11
- sdut-离散题目11
- SDUT 3805 离散题目11
- 离散题目11--判断双射
- 离散题目11 判断双射
- 离散题目11(判双射函数)
- 离散题目3
- 离散题目7
- sdut离散题目13
- sdut离散题目14
- 离散题目12
- 离散题目15
- 3799-->离散题目5
- 3800-->离散题目6
- openGL ES进阶教程(三)用openGL实现动态壁纸,就是这么简单
- LeetCode第一题--两个数的和
- java jdk linux安装 经验
- 二叉树反序列化与直观打印
- 实现简单的邮件发送功能
- 离散题目11
- 使用screen让程序在Linux后台运行
- [小心情]单曲循环后的感想
- Jmeter登录接口
- 相机控制器-02
- Redis使用详细教程
- 安装库源文件和文档
- GCC选项 –I,-l,-L
- 播放gif 图片