SDUT-离散题目13
来源:互联网 发布:hive是数据库吗 编辑:程序博客网 时间:2024/04/29 22:49
离散题目13
Time Limit: 1000MS Memory Limit: 65536K
Problem Description
DaYu平时只顾着看电影,没有学习离散,学期末快考试的时候才慌了神,因为时间不够,因此他决定只复习一个知识点,但是他发现他一个知识点都不会,因此他跑过来请你帮他解决一个问题。求一个集合是否是自反的。
Input
第一行输入组数T(T<10),每组的第一行输入集合元素个数m(m < 100)和对应关系个数n(n < 100),集合中元素为1,2,…,m,接下来n行每行输入两个数x,y(0 < x, y < 100)
Output
如果满足自反关系,则输出true,否则输出false。
Example Input
25 91 11 22 23 32 34 44 55 55 15 81 11 22 23 32 34 44 55 1
Example Output
truefalse
Hint
Author#include<bits/stdc++.h>using namespace std;int main(){ int a[111],b[111],t; int c[111][111]; scanf("%d",&t); while(t--) { int n,m,i,tt=0; scanf("%d%d",&n,&m); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); for(i=0;i<m;i++) { scanf("%d%d",&a[i],&b[i]); c[a[i]][b[i]]=1; } for(i=0;i<m;i++) { if(c[a[i]][a[i]]!=1)//此题的最保险做法:桶排设二维数组直接判是否每个c[a[i]][a[i]]==1 { tt=1; break; } } if(tt==0) { printf("true\n"); } else { printf("false\n"); } }}
阅读全文
0 0
- sdut离散题目13
- SDUT-离散题目13
- sdut-离散题目13
- SDUT 3807 离散题目13
- sdut离散题目11
- sdut离散题目14
- SDUT-离散题目7
- SDUT离散题目4
- sdut-离散题目3
- sdut- 离散题目4
- sdut-离散题目5
- sdut-离散题目6
- sdut-离散题目7
- sdut-离散题目8
- sdut-离散题目9
- sdut-离散题目10
- sdut-离散题目11
- sdut-离散题目12
- 提升效率的一些小工具推荐
- c++第五次作业
- Codeforces 622C Not Equal on a Segment (并查集思想)
- 冒泡排序-BubbleSort
- 解决Cython在Window下Python2.7中:Unable to find vcvarsall.bat的问题
- SDUT-离散题目13
- HDU1506
- Java 里的数据类型基本知识
- 启动和停止MySQL服务
- apache 2.4.23 只能本地访问,其他用户不能访问,提示You don't have permission to access
- errno详解
- Java常见异常类型及原因分析(下)
- Qt5:LNK2001: 无法解析的外部符号 "public: static struct QMetaObject const Newspaper::staticMeta
- [深度学习论文笔记][ECCV16]Laplacian Pyramid Reconstruction and Renement for Semantic Segmentation