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. vs2010 “SetScrollSizes”: 找不到标识符

    SetScrollSizes是CScrollView的成员函数,你的view类必须从CScrollView派生

  2. 安装包制作工具 SetupFactory使用2 API清单

    2014-11-19 SetupFactory中可以通过其API控制很复杂的业务需求. 下图中展示了其内置的API种类与具体分类函数.   序号 API名称 API说明 1 Application.E ...

  3. 数据库防火墙如何防范SQL注入行为

    SQL注入是当前针对数据库安全进行外部攻击的一种常见手段.现有主流应用大多基于B/S架构开发,SQL注入的攻击方式正是利用web层和通讯层的缺陷对数据库进行外部恶意攻击.将SQL命令巧妙的插入通讯的交 ...

  4. Thrift搭建分布式微服务(四)

      第一篇 <连接配置> 第二篇 <连接池> 第三篇 <标准通信> 第四篇 快速暴露接口 之前的文章,我们介绍了如何使用连接池管理Thrift节点,以及使用Thri ...

  5. jquery.form.js表单插件的使用

    jquery.form.js官网:http://malsup.com/jquery/form API文档:http://malsup.com/jquery/form/#api 下载地址:http:// ...

  6. Bootstrap系列 -- 16. 文本域textarea

    文本域和原始使用方法一样,设置rows可定义其高度,设置cols可以设置其宽度.但如果textarea元素中添加了类名“form-control”类名,则无需设置cols属性.因为Bootstrap框 ...

  7. Objective-C 高性能的循环遍历 forin - NSEnumerator - 枚举 优化

    Cocoa编程的一个通常的任务是要去循环遍历一个对象的集合  (例如,一个 NSArray, NSSet 或者是 NSDictionary). 这个看似简单的问题有广泛数量的解决方案,它们中的许多不乏 ...

  8. web服务器

    1.打破信息孤岛,实现信息的集成 2.配置文件  web.xml          定义自己的服务器应该要哪些功能! 3.tomcat 是一个servlet容器,一个web服务器. 部署:将web应用 ...

  9. oracle 的安装脚本

    ==[root@oracle ~]# cat 1.preusers.sh ==#!/bin/bash#Purpose:Create 3 groups named 'oinstall','dba','o ...

  10. Maven-环境快速搭建

    Jdk  1.5以上java开发环境. Eclipse IDE 一个. Maven 3.0.3下载地址: http://maven.apache.org/docs/3.0.3/release-note ...