若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1128: Problem D: Forests

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,468

题目描述

Problem D: Forests
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).
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 T and P followed by several lines, containing a pair of integers i and j, indicating that person i has heard tree j fall. People may have different opinions as to which trees, according to Berkeley, have made a sound. 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.

输入

暂无

输出

暂无

样例输入

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

样例输出

2

参考代码

int obs[200][200];
int done[200];
main() 
{
    int P,T,i,j=0,k,cnt=0;
    scanf("%d%d",&P,&T);
    while (2 == scanf("%d%d",&i,&j)) 
    {
        obs[i][j] = 1;
    }
    for (i=1;i<=P;i++) 
    {
        if (done[i]) continue;
        cnt++;
        for (j=i;j<=P;j++) 
        {
            for (k=1;k<=T && obs[i][k]==obs[j][k];k++);
            if (k > T) done[j] = 1;
        }
    }
    printf("%dn",cnt);
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist