题目链接:

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. 修改apche的端口号为80后,重启不成功,怎么办

    修改为80后提示如下 Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' f ...

  2. CentOS 7.0 Firewall防火墙配置

    启动停止 获取firewall状态 systemctl status firewalld.service firewall-cmd --state 开启停止防火墙 开机启动:systemctl ena ...

  3. 杂谈--SQL SERVER版本

    SQL SERVER 内部版本号: SQL   Server Version Internal Database Version SQL Server 2014 782 SQL Server 2012 ...

  4. Ocelot入门实践

    博主是第一次写技术文档,一是对这两年工作以来的一些技术和经验进行整理,二也是希望能和大家多多分享交流,如有写的不对的地方望大家多多指正.进入正题 Ocelot 概念就不说了,大家自行百度,今天做一个O ...

  5. 【BZOJ3160】 万径人踪灭(FFT,manacher)

    前言 多项式真的很难♂啊qwq Solution 考虑求的是一个有间隔的回文串,相当于是: 总的答案-没有间隔的答案 考虑总的答案怎么计算?FFT卷一下就好了. 对于每一位字符,有两种取值,然后随便卷 ...

  6. 【新手向】阿里云上ubuntu+flask+gunicorn+nginx服务器部署(二)项目部署

    本项目实现的是类似于ins的图片分享网站.继续(一),当nginx的配置已修改好后,要在远程服务器上部署网站,只需要几个步骤: 1 前期准备 2 将运行网站的代码从github上下载过来 3 下载依赖 ...

  7. 跟着刚哥学习Spring框架--Spring容器(二)

    Spring容器 启动Spring容器(实例化容器) -- IOC容器读取Bean配置创建Bean实例之前,必须对它进行实例化(加载启动),这样才可以从容器中获取Bean的实例并使用.  Bean是S ...

  8. C#6.0语言规范(九) 命名空间

    C#程序使用命名空间进行组织.命名空间既可以用作程序的“内部”组织系统,也可以用作“外部”组织系统 - 一种呈现暴露给其他程序的程序元素的方式. 提供了使用指令(使用指令)以便于使用命名空间. 编译单 ...

  9. Angular使用总结 --- 模型驱动表单

    模型驱动表单 之前有篇博文总结了 模版驱动表单 , 以及 模版驱动表单的自定义校验 , 本篇总结下模型驱动表单. 与模版驱动表单是不同的编程思路,偏向于数据模型.先在组件中建立表单控件的对象树,再绑定 ...

  10. rpm安装JDK方法

    由于版权原因,Linux发行版并没有包含官方版的Oracle JDK,必须自己从官网上下载安装.Oracle官网用Cookie限制下载方式,使得眼下只能用浏览器进行下载,使用其他方式可能会导致下载失败 ...