离散题目14
来源:互联网 发布:java中匿名内部类 编辑:程序博客网 时间:2024/05/16 06:52
Problem Description
判断集合是不是对称的。
Input
首先输入两个数n,m表示集合中元素的个数,以及存在的关系数。
接下来1行包含n个以空格分隔的整数。
接下来m行,每行包含两个数a,b表示关系。
(1< = n < = 1000,1 < = a,b < = n,m < = n*(n-1)&& m < = 1000)
Output
对于每组输入,如果这个集合是对称的则输出“YES”,否则输出“NO”。(均不包含引号)
Example Input
5 81 11 22 13 32 33 24 55 45 91 11 22 13 32 33 24 55 45 1
Example Output
YESNO
code:
#include<stdio.h>#include<string.h>int main(){ int n, m, i, j; int a[1010][1010]; while(~scanf("%d%d", &n, &m)) { memset(a, 0, sizeof(a)); while(m--) { scanf("%d%d", &i, &j); a[i][j]++; } int flag = 1; for(i = 1; i<=n; i++) { for(j = 1; j<=n; j++) { if(a[i][j]!=a[j][i]) { flag = 0; break; } } } if(flag) printf("YES\n"); else printf("NO\n"); }}
阅读全文
0 0
- sdut离散题目14
- 离散题目14
- 离散题目14
- 离散题目14
- 离散题目14
- sdut-离散题目14
- SDUT 3808 离散题目14
- 离散题目14--判断集合的对称性
- 离散题目14 判断是否对称
- 离散题目3
- 离散题目7
- sdut离散题目11
- sdut离散题目13
- 离散题目12
- 离散题目15
- 3799-->离散题目5
- 3800-->离散题目6
- 离散题目1
- 【PMP认证考试之个人总结】第 8 章 人力资源管理
- 【转】Makefile中的foreach函数
- mysql的操作语句
- atomic包的原理及分析
- android Rxjava 使用心得
- 离散题目14
- DUBBO用户指南(笔记)
- 【影评】摔跤吧爸爸!
- system:udev原理分析
- C语言-数据结构-线性表检索和二分检索
- 配置你的Editor
- ideal手动添加jar包
- cnpm 安装 node-sass & sass-loader, 仍旧无法编译的原因
- 基于vue2全家桶实现的,仿移动端QQ