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

Description

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

Source

 #include<stdio.h>
#include<set>
#include<string.h>
using namespace std; set <int> a[] ;
bool flag [] ;
int t , p ;
//set <int> :: iterator it ;迭代器 int main ()
{
//freopen ("a.txt" , "r" , stdin ) ;
memset (flag , , sizeof(flag) ) ;
scanf ("%d%d" , &t , &p ) ;
int i , j ;
int cnt = ;
while (~ scanf ("%d%d" , &i , &j) ) {
a[i].insert (j) ;
}
for (int i = ; i < p ; i++) {
if (flag[i] == ) {
flag[i] = ;
for (int j = i + ; j <= p ; j++) {
if (a[i] == a[j]) {
flag [j] = ;
}
}
cnt ++ ;
}
}
printf ("%d\n" , cnt ) ;
return ;
}

从师兄们那学来的orz ,首先知道了如何把set中的元素输出:

set <int> ::iterator it ;

for (it = a.begin () ; it <= a.end () ; i++ )

  printf ("%d " , *it ) ;

----------接下来是如何判断两个set集合相等----------

简单粗暴orz:

set <int> a , b ;

if (a == b) {

  puts ("Yes") ;

}

else {
  puts ("No") ;

}

poj.2419.Forests (枚举 + set用法)的更多相关文章

  1. POJ 2419 Forests(模拟)

    题目链接: https://cn.vjudge.net/problem/POJ-2419 题目描述: If a tree falls in the forest, and there's nobody ...

  2. poj 1873 凸包+枚举

    The Fortified Forest Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6198   Accepted: 1 ...

  3. C++枚举类型Enum及C++11强枚举类型用法

    C++中的枚举类型常常和switch配合使用,这里用一个简单的switch控制键盘回调的代码片段来说明枚举的用法: //W A S D 前.后.左.右行走 enum Keydown{ Forward= ...

  4. Java enum(枚举)的用法详解(转)

    用法一:常量 在JDK1.5 之前,我们定义常量都是: public static fianl.... .现在好了,有了枚举,可以把相关的常量分组到一个枚举类型里,而且枚举提供了比常量更多的方法. p ...

  5. poj 1106 Transmitters (枚举+叉积运用)

    题目链接:http://poj.org/problem?id=1106 算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小 ...

  6. POJ 1018 【枚举+剪枝】.cpp

    题意: 给出n个工厂的产品参数带宽b和价格p,在这n个工厂里分别选1件产品共n件,使B/P最小,其中B表示n件产品中最小的b值,P表示n件产品p值的和. 输入 iCase n 表示iCase个样例n个 ...

  7. (转载)C# 枚举 FlagsAttribute用法

    这是读过几篇文章后发现整理的最完整的一篇文章 转载地址:枚举特性FlagsAttribute的用法 先看官方的解释:指示可以将枚举作为位域(即一组标志)处理. 看起来并不好理解,到底什么是作为位域处理 ...

  8. C# 枚举基本用法及扩展方法

    没什么好说的,都是些基础! 代码如下: using System; using System.Collections.Generic; using System.ComponentModel; usi ...

  9. Java ENUM枚举的用法

    DK1.5引入了新的类型——枚举.在 Java 中它虽然算个“小”功能,却给我的开发带来了“大”方便. 用法一:常量 在JDK1.5 之前,我们定义常量都是: publicstaticfianl... ...

随机推荐

  1. WP&Win10开发: RichTextBlock实现富文本并处理换行

    思路:1.构建字典.2.在字符串中匹配字典的key,将匹配到的key转换成对应的value3.将替换后的字符串,转化成xaml形式,加载该xaml以实现富文本. 代码如下: private Parag ...

  2. Scala学习笔记(七):Application特质

    Scala提供了特质scala.Application 在单例对象名后面写上“extends Application”,把想要执行的代码直接放在单例对象的花括号之间 import ChecksumAc ...

  3. MVC采用HtmlHelper扩展和Filter封装验证码的功能

    最近因为有个项目除了登录还有其他很多地方需要用到验证码的功能,所以想到了采用HtmlHelper和ActionFilter封装一个验证码的功能,以便能够重复调用.封装好以后调用很方便,只需在View中 ...

  4. “未能加载文件或程序集“EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”

    产生原因: 使用nuget管理程序包,同一个解决方案里面有不同版本的Entity Framework,有可能在不同时间安装不同版本的Entity Framework,所以出现这个问题. 解决方案: 1 ...

  5. [C#]Attribute特性(2)——方法的特性及特性参数

    上篇博文[C#]Attribute特性介绍了特性的定义,类的特性,字段的特性,这篇博文将介绍方法的特性及特性参数相关概念. 3.方法的特性 之所以将这部分单列出来进行讨论,是因为对方法的特性查询的反射 ...

  6. 2016 版 Laravel 系列入门教程(五)【最适合中国人的 Laravel 教程】

    本教程示例代码见: https://github.com/johnlui/Learn-Laravel-5 在任何地方卡住,最快的办法就是去看示例代码. 本文是本系列教程的完结篇,我们将一起给 Arti ...

  7. php 一次性替换多个关键词

    str_replace(find,replace,string,count) 参数 描述 find 必需.规定要查找的值. replace 必需.规定替换 find 中的值的值. string 必需. ...

  8. 微信WeixinJSBridge API

    <!DOCTYPE html><html> <head> <title>微信WeixinJSBridge API</title> <m ...

  9. Chrome的Crash Report服务

    <本文转自:http://www.cppblog.com/woaidongmao/archive/2009/10/22/99211.aspx> 本文翻译自debugInfo网站上一篇文章g ...

  10. Daily Scrum – 1/7

    Meeting Minutes 搞定了一个bug,单词面板滚动条的bug: 在电脑屏幕上的屏幕适配有了新思路: Progress   part 组员 今日工作 Time (h) 明日计划 Time ( ...