POJ 2419 Forests(模拟)
题目链接:
https://cn.vjudge.net/problem/POJ-2419
题目描述:
Input
Output
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(模拟)的更多相关文章
- poj.2419.Forests (枚举 + set用法)
Forests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5782 Accepted: 2218 Descripti ...
- poj 3077Rounders(模拟)
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...
- POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
- POJ 1036 Rails 模拟堆栈
水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x= ...
- POJ 1001 Exponentiation 模拟小数幂
模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostrea ...
- POJ 1008 简单模拟题
e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...
- Crashing Robots POJ 2632 简单模拟
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...
- poj 1806 分块模拟
Manhattan 2025 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1318 Accepted: 703 Des ...
- poj 1472(递归模拟)
题意:就是让你求出时间复杂度. 分析:由于指数最多为10次方,所以可以想到用一个数组保存各个指数的系数,具体看代码实现吧! 代码实现: #include<cstdio> #include& ...
随机推荐
- nodeclub models
之前看过keystone的结构,所以现在看nodeclub时,总会和keystone进行比较. nodeclub models会有一个index来作为facade,通过它连接mongodb,expor ...
- js-实现双色球功能
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- js-图片时间困难版(倒计时)
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> ...
- bootstrap 警告框单个删除
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- 服务器重启报错:提示fstab readonly报错!( /etc/fstab 只读无法修改的解决办法)
摘自:http://blog.csdn.net/gray13/article/details/7432866 一.问题描述:服务器重启报错:提示fstab readonly报错! 二.问题原因:挂载的 ...
- Delphi程序带参数运行
程序1 program E1; uses Forms,Dialogs,SysUtils, EndM1 in 'EndM1.pas' {Form2}; {$R *.res} begin Applicat ...
- delphi中OleContainer的使用总结
1:定义流的header , OleContainer要求流中要有Headertype //流Header的结构 TStreamHeader = record Signature: Integer; ...
- node-webkit学习(4)Native UI API 之window
node-webkit学习(4)Native UI API 之window 文/玄魂 目录 node-webkit学习(4)Native UI API 之window 前言 4.1 window a ...
- .NET Entity Framework (with Oracle ODP.NET) -Code First
上一篇文章介绍了.NET Entity Framework ,并演示了Model First模式,本文将继续讨论 Code First 模式的实现. 一.摘要 1.目标 本文验证了通过Oracle D ...
- 关于nginx部署vue项目的两个问题
首先我使用的是后端接口+前端vue的形式,这样就涉及到跨域的问题.我是这样配置的: server { listen 80; server_name www.liangyp.xyz;//访问网址 loc ...