离散题目12
来源:互联网 发布:赚钱宝映射哪些端口号 编辑:程序博客网 时间:2024/06/09 12:21
离散题目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 34 5 631 42 53 61 2 34 5 631 41 51 6
Example Output
yesno
think:此题只需要判断一下自变量不是重复的就可以。
代码:#include <bits/stdc++.h>using namespace std;int main(){int x[20005],y[20005], i, flag, n;string ss, tt;while(getline(cin, ss)){getline(cin, tt);cin>>n;flag = 1;for(i = 0; i < n; i++)cin>>x[i]>>y[i];sort(x, x+n);for(i = 0; i <= n-2; i++){if(x[i] == x[i+1]){flag = 0;break;}}if(flag)cout<<"yes"<<endl;else cout<<"no"<<endl;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
- Lua math 库
- freemarker是什么东西?
- hdu 1272 小希的迷宫
- Python 中常用的函数和技巧
- USCAO-Section1.1 Friday the Thirteenth
- 离散题目12
- PHP_实现四种基本排序算法
- 防止数据重复,通过session保存url和请求参数来校验
- PAT1025
- scala的lazy
- linux内核电源管理浅析
- C语言学习笔记-函数-郝斌
- LeetCode 520:Detect Capital
- linux关于bashrc与profile的区别