离散题目9
来源:互联网 发布:plc称重模块怎样编程 编辑:程序博客网 时间:2024/06/05 11:34
离散题目9
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
给定一个数学函数F和两个集合A,B,写一个程序来确定函数是单射。
即A中的任意一个元素唯一的对应一个函数值,并且该值为B集合中的某个元素。
Input
多组输入。
首先输入集合的元素数n<=100000。
接下来的一行输入n 个整数0<=ai<=n。
接下来的一行输入n个整数 0<=bi<=n。
接下来的一行输入2n个整数ci,并且当ci的下标为奇数时表示A集合中的元素,当ci的下标为偶数时表示A集合中元素对应的函数值(即B集合的元素)。
Output
(一组答案占一行)
当满足单射关系时输出yes
不满足关系时输出no
Example Input
4
1 3 5 7
2 5 6 8
1 2 3 2 5 8 7 6
2
1 4
3 5
1 3 1 5
Example Output
yes
no
#include <stdio.h>#include <string.h>int a[100010],b[100010],c[100010],d[100010];int main(){ int n,x,y; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for (int i=0; i<n; i++) { scanf("%d",&x); a[x]=1; } for (int i=0; i<n; i++) { scanf("%d",&x); b[x]=1; } int flag=1; for (int i=0; i<n; i++) { scanf("%d %d",&x,&y); a[x]++; if (a[x]==2&&b[y]==1) { } else { flag=0; } } if (flag) { printf("yes\n"); } else { printf("no\n"); } } return 0;}
阅读全文
0 0
- 离散题目9
- 离散题目9
- 离散题目9
- 离散题目9
- sdut-离散题目9
- SDUT 3803 离散题目9
- 离散题目9--判断单射
- 离散题目9 判断单射
- 离散题目3
- 离散题目7
- sdut离散题目11
- sdut离散题目13
- sdut离散题目14
- 离散题目12
- 离散题目15
- 3799-->离散题目5
- 3800-->离散题目6
- 离散题目1
- I/O复用之select、poll、epoll函数
- linux-基本命令
- redis入门之持久化方式
- Ubuntu下Linux C程序的创建
- Ajax
- 离散题目9
- Linux下Python的一些基础相关问题(1)
- c++ 时间类型详解(time_t和tm)
- B轮融资获数千万美元,柏睿数据到底牛在哪?
- ANDROID获取WEBVIEW中网页的TITLE(标题)信息
- java集合(2):ArrayList源码分析
- 一周乱弹(1,spring 获取 servletContext 方式 2,Calendar常用操作及与date,string的转换)
- JavaScript--2048游戏(一)
- 2014第五届蓝桥杯国赛决赛c/c++本科B组试题总结及解题答案