题目链接:

https://cn.vjudge.net/problem/POJ-2419

题目描述:

If a tree falls in the forest, and there's nobody there to hear, does it make a sound? This classic conundrum was coined by George Berkeley (1685-1753), the Bishop and influential Irish philosopher whose primary philosophical achievement is the advancement of what has come to be called subjective idealism. He wrote a number of works, of which the most widely-read are Treatise Concerning the Principles of Human Knowledge (1710) and Three Dialogues between Hylas and Philonous (1713) (Philonous, the "lover of the mind," representing Berkeley himself).

Input

A forest contains T trees numbered from 1 to T and P people numbered from 1 to P. Standard input consists of a line containing P and T followed by several lines, containing a pair of integers i and j, indicating that person i has heard tree j fall.

Output

People may have different opinions as to which trees, according to Berkeley, have made a sound. Output how many different opinions are represented in the input? Two people hold the same opinion only if they hear exactly the same set of trees. You may assume that P < 100 and T < 100.

Sample Input

3 4
1 2
3 3
1 3
2 2
3 2
2 4

Sample Output

2
 /*
题意描述
有p个人去听t棵树倒下的声音,问有几种不同的观点数 解题思路
用二维数组记录i听到j倒下,如果某个人听到的结果和另一个完全相同,说明这两个人是一种观点,需要总观点数减一
*/
#include<cstdio>
#include<cstring>
const int maxn=+; bool g[maxn][maxn];
int t,p;
int common(int a,int b); int main()
{
int x,y;
memset(g,,sizeof(bool)*maxn*maxn);
scanf("%d%d",&p,&t);
while(scanf("%d%d",&x,&y) != EOF){
g[x][y]=;
}
int sum=p;
for(int i=;i<=p-;i++){
for(int j=i+;j<=p;j++){
if(common(i,j)){
sum--;
break;//遇到一个重复以后,总观点数减1后直接判断下一个
}
}
}
printf("%d\n",sum);
return ;
} int common(int a,int b)
{
for(int i=;i<=t;i++){
if(g[a][i] != g[b][i])
return ;
}
return ;
}

POJ 2419 Forests(模拟)的更多相关文章

  1. poj.2419.Forests (枚举 + set用法)

    Forests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5782   Accepted: 2218 Descripti ...

  2. poj 3077Rounders(模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...

  3. POJ 1068 Parencodings 模拟 难度:0

    http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...

  4. POJ 1036 Rails 模拟堆栈

    水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x= ...

  5. POJ 1001 Exponentiation 模拟小数幂

    模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostrea ...

  6. POJ 1008 简单模拟题

    e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...

  7. Crashing Robots POJ 2632 简单模拟

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

  8. poj 1806 分块模拟

    Manhattan 2025 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1318   Accepted: 703 Des ...

  9. poj 1472(递归模拟)

    题意:就是让你求出时间复杂度. 分析:由于指数最多为10次方,所以可以想到用一个数组保存各个指数的系数,具体看代码实现吧! 代码实现: #include<cstdio> #include& ...

随机推荐

  1. unigui的ServerModule常用属性设置

    unigui的ServerModule常用属性设置 1)压缩设置 compression是压缩数据用的.默认启用压缩,且压缩级别是最大的. 2)UNIGUI运行时库设置 UNIGUI需要4个运行时库, ...

  2. Http站点转Https站点教程

    https://blog.csdn.net/tanga842428/article/details/79273226 Http站点转Https站点教程 2018年02月28日 12:04:35 坦GA ...

  3. win7 docker 挂载共享目录

    在 win7 下用 docker 不像 win10 那样方便,安装包都不一样. 在 win7 下共享一个目录的方法如下: 1. 先设置 win7 到 VirtualBox 中 docker 用的那个虚 ...

  4. Redis---skipList(跳跃列表)

    1. 概述 跳跃表是一种有序的数据结构, 他通过在每个节点中维持多个指向其他节点的指针, 从而达到快速访问节点的目的. 大部分情况下, 跳跃表的效率可以和平衡树相媲美. Redis中只在两处用到了跳跃 ...

  5. Javascript如何避免连续调用中取到不存在的属性而导致报TypeError错?

    背景: 在最近的 NODEJS 项目中,涉及到数据库的查询,回调函数里返回了查询结果,我这样做处理然后返回给前端: return results.collect_coupon[0].count 但是这 ...

  6. zabbix 监控安装

    注意:此篇是在安装好lnmp环境后才能部署的操作,所以,做之前准备好lnmp环境,或者可以参考我做的lnmp环境,之后接着此篇开始安装 监控系统Zabbix-3.2.1的安装 zabbix-serve ...

  7. Liferay7 BPM门户开发之1:Liferay7开发环境准备

    liferay sdk下载 \IDE下载 \ Tomcat 安装细节不在此赘述 网上有很多. 只讲核心关键坑点 进入2016年,从Liferay6.2.5 ga6版本开始,到7.0 ga3,在ivy环 ...

  8. 人工智能-机器学习之Selenium(chrome驱动,火狐驱动)

    selenium是一个用于web应用程序测试的工具,Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包括IE.Mozilla Firefox.Mozilla Suite等 ...

  9. 基础I/O接口与操作

    C语言中的文件接口 1 打开文件 FILE * fopen(const char * path,const char * mode) 参数:path:文件路径 mode:打开文件的方式 返回值:成功返 ...

  10. iOS UIFileSharingEnabled

    一.让iOS App通过iTunes进行文件交换Documents 让iOS App通过iTunes进行文件交换 有一些App需要通过使用iTunes让用户上传和下载文档.要让iOS程序支持iTune ...