sdut-离散题目14
来源:互联网 发布:wii 知乎 编辑:程序博客网 时间:2024/06/04 18:23
离散题目14
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
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 8
1 1
1 2
2 1
3 3
2 3
3 2
4 5
5 4
5 9
1 1
1 2
2 1
3 3
2 3
3 2
4 5
5 4
5 1
Example Output
YES
NO
提示: 双层for 循环下面, 如果ij存在 判断 是否ji存在就可以了,还有 多组输入,学长不走心,没有说明白
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int map[1300][1300];int a[1300];int b[1300];int n,m;int main (){ int i,j,k; while (~scanf("%d %d",&n,&m) ) { memset(map,0,sizeof(map)); for(i=0;i<m;i++) { scanf("%d %d",&j,&k); map[j][k]=1; a[i]=j; b[i]=k; } int flag=0; for(i=0; i<m; i++) { for(j=0; j<m; j++) { if(map[a[i]][b[i]]==1) { if(map[b[i]][a[i]]==0) { flag=1; break; } } } } if(flag==1) printf("NO\n"); else printf("YES\n"); }}
阅读全文
0 0
- sdut离散题目14
- sdut-离散题目14
- SDUT 3808 离散题目14
- sdut离散题目11
- sdut离散题目13
- SDUT-离散题目13
- SDUT-离散题目7
- SDUT离散题目4
- sdut-离散题目3
- sdut- 离散题目4
- sdut-离散题目5
- sdut-离散题目6
- sdut-离散题目7
- sdut-离散题目8
- sdut-离散题目9
- sdut-离散题目10
- sdut-离散题目11
- sdut-离散题目12
- 华为面试题
- Oracle ADF 报错:BEA-149265
- 数据库,多对多表约束
- JVM类加载机制详解(一)JVM类加载过程
- jsp数据库中文乱码处理
- sdut-离散题目14
- 选购 显微镜
- iTerm--比Terminal(终端)更好用的命令行工具
- Linux网络编程【二】:UDP socket套接字详解
- If you encounter a maven error on your pom file saying web.xml is missing
- Java基础-异常处理、常用类
- ThreadPoolExecutor使用详解
- leetcode 139. Word Break
- 实战