离散题目12
来源:互联网 发布:全面战争战锤 linux 编辑:程序博客网 时间:2024/05/21 06:33
离散题目12
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
给出两个集合,以及两个集合上的关系。判断该关系能不能构成函数
Input
多组输入。第一行数字表示集合A;第二行数字表示集合B;第三行一个数字N,表示关系的个数。以下N行,每行两个数字a b,用来描述关系a→b。0 < n < = 20000,集合A、B的大小不超过10000.
Output
每组数据输出一行,所给关系属于函数,输出’yes’ ,否则输出‘no’。
Example Input
1 2 3
4 5 6
3
1 4
2 5
3 6
1 2 3
4 5 6
3
1 4
1 5
1 6
Example Output
yes
no
Think:判断集合A中的元素是否都出现且出现一次
#include <stdio.h>#include <algorithm>using namespace std;int main(){ char a[111111]; char b[111111]; while(gets(a)) { gets(b); int n; int aa[111111]; int bb[111111]; scanf("%d",&n); int i; for(i=0; i<n; i++) { scanf("%d %d",&aa[i],&bb[i]); } sort(aa,aa+n); int k=0; for(i=0; i<n-1; i++) { if(aa[i]==aa[i+1]) { k=1; break; } } if(k==0) printf("yes\n"); else printf("no\n"); getchar(); getchar(); } return 0;}
阅读全文
0 0
- 离散题目12
- 离散题目12
- 离散题目12
- 离散题目12
- 离散题目12
- 离散题目12
- 离散题目12
- 离散题目12
- sdut-离散题目12
- SDUT 3806 离散题目12
- 离散题目3
- 离散题目7
- sdut离散题目11
- sdut离散题目13
- sdut离散题目14
- 离散题目15
- 3799-->离散题目5
- 3800-->离散题目6
- bzoj1336: [Balkan2002]Alien最小圆覆盖&&1337: 最小圆覆盖
- JDBC处理transaction
- cpu 调频
- Android 7.0 android.os.NetworkOnMainThreadException
- [BZOJ1055][HAOI2008]玩具取名 记忆化搜索
- 离散题目12
- JSP动作标签useBean--<jsp:useBean> 创建一个对象
- UVa 12100
- 使用背景优先级的测地显著性检测(Geodesic Saliency Using Background Priors)
- 设计模式(9)——装饰器模式
- 知识点:求乘法逆元的几种方法
- [增强学习][Reinforcement Learning]学习笔记与回顾-2-马尔可夫决策过程MDP
- IIS发布以及遇到到问题
- tomcat各个组件功能