题目链接:

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. jdbc的配置(更新中)

    MySQL的 JDBC URL 格式 for  Connector/J 如下例: 格式如下: jdbc:mysql://[host][,failoverhost...][:port]/[databas ...

  2. java 判断手机号码和邮箱的正则表达式

    很多场合会用到判断输入框输入的是否为手机或者邮箱,下面是这个正则表达式: Pattern  patternMailBox  = Pattern .compile( "^([a-zA-Z0-9 ...

  3. Python自动化开发 - 装饰器

    本节内容 一.装饰器导引 1.函数对象特性 2.扩展业务功能需求 3.各种解决方案 二.装饰器解析 1.装饰器基本概念 2.无参装饰器解析 一.装饰器导引 1.函数对象特性 #### 第一波 #### ...

  4. [php] php - json_encode 函数

    json_encode()函数, $arr= array("key"=>null); echo json_encode($arr);{"key":null ...

  5. FastReport调整字体

  6. redis集群(主从配置)

    市面上太多kv的缓存,最常用的就属memcache了,但是memcache存在单点问题,不过小日本有复制版本,但是使用的人比较少,redis的出现让kv内存存储的想法成为现实.今天主要内容便是redi ...

  7. asp.net 增加404页面(非302、200)

    由于项目改版,导致产生了许多死链,但是之前的404页面都是在Application_Error中Response.Redicet()到404页面,但是这样子是302跳转,导致搜索引擎认为网页不是死链而 ...

  8. Asp .Net core 2 学习笔记(2) —— 中间件

    这个系列的初衷是便于自己总结与回顾,把笔记本上面的东西转移到这里,态度不由得谨慎许多,下面是我参考的资源: ASP.NET Core 中文文档目录 官方文档 记在这里的东西我会不断的完善丰满,对于文章 ...

  9. 2019年微服务实践第一课,网易&谐云&蘑菇街&奥思技术大咖深度分享

    微服务的概念最早由Martin Fowler与James Lewis于2014年共同提出,核心思想是围绕业务能力组织服务,各个微服务可被独立部署,服务间是松耦合的关系,以及数据和治理的去中心化管理.微 ...

  10. 不一样的网络流系列——Dinic跑得快

    前言 摆王兴致冲冲地跑到我们机房来对我说跟你讲一个黑科技... Dinic的神奇优化 Dinic优化 我们发现如果Dinic不建反向边会跑的飞起(当然Wa是必然的) 所以考虑在加反向边的基础上优化. ...