POJ 2419 Forests
来源:互联网 发布:网络工程施工费用 编辑:程序博客网 时间:2024/06/05 03:12
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 41 23 31 32 23 22 4
Sample Output
2
Source
Waterloo Local 2002.01.26
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~二进制~
(其实我也不知道该分为什么……明明就是大暴力嘛……
用两个long long记录每个人听见的树,然后暴力比对就可以了~
读入优化不可以用在EOF里面啊!
#include<cstdio>#include<iostream>#include<algorithm>using namespace std;#define ll long longint n,m,tot,x,y;ll a[101][2],num[101][2];bool flag;int read(){int x=0,f=1;char ch=getchar();while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}while(ch>='0' && ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f; }int main(){n=read();m=read();while(scanf("%d",&x)!=EOF){y=read();y--;if(y<50) a[x][0]|=(1<<y);else a[x][1]|=(1<<(y-50));}for(int i=1;i<=n;i++){flag=0;for(int j=1;j<=tot;j++) if(a[i][0]==num[j][0] && a[i][1]==num[j][1]) {flag=1;break; }if(!flag) num[++tot][0]=a[i][0],num[tot][1]=a[i][1];}printf("%d\n",tot);return 0;}
1 0
- poj 2419 Forests
- POJ 2419 Forests
- POJ 2419 Forests 笔记
- ACM Hrbeu OJ 1001 Forests || POJ 2419
- POJ 1268 Forests 笔记
- Forests
- Random Forests
- random forests
- Random Forests
- Random forests, 随机森林,online random forests
- Random Forests原理
- [基础算法] Random Forests
- UVA 10227 - Forests
- Random Forests原理
- UVa 10227 - Forests
- Forests of randomized trees
- Deep Neural Decision Forests
- Mahout Random Forests
- 学习笔记3
- laravel学习笔记(5)— Blade模板引擎
- vimgrep 用法
- CSU
- python数据分析与挖掘实践—拉格朗日插值法
- POJ 2419 Forests
- 萌新瞎讲【分块】
- 【MPI学习5】MPI并行程序设计模式:组通信MPI程序设计
- Windows不能在本地计算机启动MongoDB,错误代码 100
- as 配置注释模板
- 四月英语——一个反复的日子
- 【MPI学习6】MPI并行程序设计模式:具有不连续数据发送的MPI程序设计
- POJ
- CSDN日报20170430 ——《Review 2017 年度计划》