poj2186 Popular Cows(强连通缩点)

IDCNBSAIS-财务报表功能范围取值管理费用、销售费用、研发费用排除指定科目的实现 研究了很多方法,没有办法实现,只在营业费用增加一个冲抵项解决,也咨询了外部顾问说要建立自建表。限于需要马上修正后面只能用了最最low的办法处理了一下。公司遇到的一个问题,目前报表有些项目是按照功能范围取值的,发现取多了。IDCNBSAIS-财务报表功能范围取值管理费用、销售费用、研发费用排除指定科目的实现。最后结果是正确的,但是总觉得有更好的办法,不知道有没有高人可以指点一下?建立一个调整项的目录,在每个节点做了调整。除了研发费用做了冲抵在以下每个节点都做了冲抵。为财务报表定义表格结构。 阅读详情

Popular Cows
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 28016 Accepted: 11294

Description

Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks that cow B is popular. Since popularity is transitive, if A thinks B is popular and B thinks C is popular, then A will also think that C is
popular, even if this is not explicitly specified by an ordered pair in the input. Your task is to compute the number of cows that are considered popular by every other cow.

Input

* Line 1: Two space-separated integers, N and M

* Lines 2..1+M: Two space-separated numbers A and B, meaning that A thinks B is popular.

Output

* Line 1: A single integer that is the number of cows who are considered popular by every other cow.

Sample Input

3 3
1 2
2 1
2 3

Sample Output

1

Hint

Cow 3 is the only cow of high popularity.

Source





#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<cmath>
#include<map>
#include<set>

typedef long long ll;
#define eps 1e-8

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)
#define bug printf("hi\n")
using namespace std;
#define INF 0x3f3f3f3f
#define N 10005

int head[N],dfn[N],low[N],belong[N];
bool instack[N];
int all,Time,num;
int out[N];
int n,m;
stack<int>s;

struct stud{
   int to,ne;
}e[N*5];

inline void add(int u,int v)
{
	e[num].to=v;
	e[num].ne=head[u];
	head[u]=num++;
}

void dfs(int u,int fa)
{
//	printf("%d\n",u);
    dfn[u]=low[u]=++Time;
	s.push(u);
	instack[u]=true;
	for(int i=head[u];i!=-1;i=e[i].ne)
	{
		int to=e[i].to;
	    if(dfn[to]==-1)
		{
			dfs(to,i);
			low[u]=min(low[u],low[to]);
		}
		else if(instack[to])
			low[u]=min(low[u],low[to]);
	}
	if(low[u]==dfn[u])
	{
		++all;
		int temp;
		do{
            temp=s.top();
		   s.pop();
		   instack[temp]=false;
		   belong[temp]=all;
		}while(temp!=u);
	}
}

int main()
{
	int i,j;
    while(~scanf("%d%d",&n,&m))
	{
		memset(head,-1,sizeof(head));
		num=0;
		int u,v;
		while(m--)
		{
			scanf("%d%d",&u,&v);
			add(u,v);
		}
		memset(dfn,-1,sizeof(dfn));
		memset(low,-1,sizeof(low));
		memset(instack,false,sizeof(instack));
        while(!s.empty()) s.pop();
		all=0;
	    Time=0;
  //  bug;
		for(i=1;i<=n;i++)
			if(dfn[i]==-1) 
				dfs(i,-1);
	//	bug;
       memset(out,0,sizeof(out));
	   for(i=1;i<=n;i++)
		   for(j=head[i];j!=-1;j=e[j].ne)
		   {
			   int to=e[j].to;
			   if(belong[i]==belong[to]) continue;
			   out[belong[i]]++;
		   }
	   int cnt=0,last;
	   for(i=1;i<=all;i++)
		   if(out[i]==0)
		   {
			   cnt++;
			   last=i;
		   }
	   if(cnt!=1)
	   {
		   printf("0\n");
		   continue;
	   }
	   int ans=0;
	   for(i=1;i<=n;i++)
		   if(belong[i]==last) ans++;
	   printf("%d\n",ans);
	}
	return 0;
}














爬虫进阶必备:深入理解requests.Session(),提升爬虫效率与稳定性 前两天,有个朋友跟我吐槽,说自己写了个爬虫爬取某个电商网站的商品信息,刚开始跑得好好的,爬了大概几百页之后,突然就开始报错了。HTTP状态码一会儿429,一会儿403,最离谱的是有些页面明明登录了却显示未登录状态。他排查了半天也没找到原因,最后把代码发给我看。 我扫了一眼代码,发现一个典型问题:他每次请求都新建一个requests.Session(),甚至有些请求直接用了requests.get()。这就好比每次进超市都要重新注册会员,每次都重新跟服务器“握手”,不翻车才怪。 其实,这就是我们今天要聊的 阅读详情

相关推荐

【VAE学习笔记】全面通透地理解VAE(Variational Auto Encoder)

完整笔记:http://www.gwylab.com/note-vae.html 李宏毅老师的教程视频:https://www.bilibili.com/video/av15889450/?p=33 —————————————————————————————————   依据李宏毅老师的讲解,我整理了一番VAE的笔记。先简单介绍一下VAE,VAE作为一个生成模型,其基本思路是很容易理解的:把一堆真...

a312863063的博客 14万+

【POJ】Popular Cows 强连通

Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22560   Accepted: 9243 Description Every cow's dream is to become the most popular cow in the herd

poursoul 1119

给宇树Go2机器人装‘眼睛’:在Jetson Orin Nano上从零部署YOLOv5的保姆级避坑实录

本文详细介绍了在Jetson Orin Nano上为宇树Go2机器人部署YOLOv5视觉系统的完整流程,涵盖硬件选型、环境配置、模型优化及系统集成等关键步骤。针对机器人应用场景特有的离线部署、版本冲突和实时推理等挑战,提供了实用的解决方案和性能优化技巧,帮助开发者快速实现机器人的视觉能力升级。

weixin_29169505的博客 378

poj2186 Popular Cows(强连通分量tarjan)

题中给出一张有向图,不保证图连通,如果对于某个点,其他点都有至少一条路径能到达该点,该点就是符合要求的( Popular Cows),问图中有多少这样的点。 解法:求强连通分量,对强连通分量缩点,缩点后是一棵树,如果出度为0的缩点个数大于1,则符合要求的点为0个,否则出度为0的缩点(强连通分量)包含的点的个数就是答案。 求强连通分量时和双连通分量时,tarjan算法还是不同的!无向图中

emmmmmm 2356

别再手动配电脑了!手把手教你用Windows Server 2022搭建企业AD域(附DNS配置避坑指南)

本文详细介绍了如何使用Windows Server 2022搭建企业AD域,提升20+终端的管理效率。通过实战案例和避坑指南,解析AD域的核心价值、部署步骤及DNS配置技巧,帮助企业实现集中权限管理、安全策略统一部署,显著降低IT运维成本。

weixin_30652897的博客 349

SAP FI模块实操:用F-28和F-32搞定客户回款与手动清账,别再让未清项报表一团糟

本文详细解析了SAP FI模块中F-28和F-32事务代码在客户回款与手动清账中的实操应用,帮助财务人员高效管理未清项报表。通过标准清账六步法和手动清账实战技巧,解决因操作不规范导致的账务混乱问题,提升应收账款管理效率。

weixin_30292843的博客 452

POJ2186(Popular Cows)

Popular Cows Description Every cow’s dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that tell you that cow A thinks t...

weixin_43808717的博客 199

滑模控制理论(SMC)概述

滑模控制理论(SMC)概述一、背景二、数学理论三、高维拓展四、分析 一、背景 滑模控制理论(Sliding Mode Control, SMC)是一种建立在现代控制理论基础上的控制理论,主要数学核心为李雅普诺夫函数。 滑模控制的核心思想是建立一个滑模面,将被控系统拉取到滑模面上来,使系统沿着滑模面运动。滑模控制的一个优势是无视外部扰动和不确定参数,采用一种比较“暴力”的方式达到控制的目的。 其思想和反步法有些类似,但数学实现起来更加方便而不抽象。相比反步法,滑模控制没有复杂的数学计算,也不会出现“微分爆炸”

高能阿博特的博客 6万+

Popular Cows POJ 2186(强连通分解)

原题 原题链接 题目大意 题目会给一个牛的有向图,A→B意味着A认为B流行,如果A→B,B→C,则A和B都认为C流行,要求求出这群牛中被所有牛认为流行的牛的数. 题目分析 这道题中会存在一些情况例如 A→B,B→C,C→A这种,就是A B C强连通,所以需要把这些强连通的点集压缩成一个点并进行拓扑排序,然后只要找序列中的最后一个点,用dfs检查一遍是否能跑遍全图,是则输出该点被...

dashengchong6303的博客 156

Comsol 弧形声学换能器声聚焦仿真

1. 弧度和曲率半径:弧形声学换能器的形状和曲率半径对声聚焦效果有重要影响。通常,较小的曲率半径和较大的弧度可以实现更强的声聚焦效果。弧形声学换能器声聚焦是指将声波能量集中在弧形声学换能器的特定区域内,以实现更强的声场强度和分辨率。4. 数值仿真和优化:使用声学仿真软件进行数值仿真可以帮助设计和优化弧形声学换能器的声聚焦效果。通过调整几何参数、材料特性和激励信号等参数,可以模拟和优化声聚焦效果。2. 激励信号:通过调整激励信号的频率和幅值,可以实现声波在弧形声学换能器中的聚焦效果。

声学黑洞仿真工作室 1616

Python爬取谷歌学术全攻略:基于Playwright与Asyncio的高效、抗反爬虫实践

同时,文章将详细解析爬虫过程中可能遇到的各种挑战,如IP封锁、验证码、动态内容加载等,并提供切实可行的解决方案。self.logger.info(f"第 {current_page} 页解析完成,共找到 {len(page_results)} 条结果。:谷歌学术的HTML结构并非一成不变,其CSS类名和标签结构可能会发生变化,且不同地区、不同语言的界面可能存在差异,增加了数据解析的难度。self.logger.info(f"开始搜索关键词: '{keyword}',计划爬取 {max_pages} 页")

2201_76125261的博客 1550

poj2086——Popular Cows(强连通分量)

Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18349Accepted: 7390 Description Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <=

JIA_char 669

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

poj 2186 Popular Cows (强连通缩点)

1 /*************************************************** 2 题目: Popular Cows(poj 2186) 3 链接: http://poj.org/problem?id=2186 4 算法: 强连通缩点 5 思想: 首先在一个连通分量上的点性质都是一样的, 6 所以就找出所有连通图并缩...

weixin_30895603的博客 130

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

poj 2186 popular cows 强连通缩点

//缩点后必须只有一个点的出度为0,此连通块中的点才被所有的牛仰慕 //poj 2186 #include #include #include #include using namespace std; const int MAX = 10010; vector edge[MAX]; int st[MAX]; int dfn[MAX],low[MAX]; int top,bt

努力奋斗才能梦想成真 647

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

POJ - 2186 Popular Cows(强连通缩点)

题目链接:点击查看 题目大意:给出n只奶牛,以及m组可传递的关系,每组关系给出一个a和一个b,表示为a->b,意思是奶牛a觉得奶牛b很酷,因为关系可传递,所以如果a->b且b->c,能够推出a->c,现在问有多少只奶牛,可以被其他所有的奶牛都认为很酷 题目分析:题目给出的是有向边,且满足条件的奶牛肯定可以被所有的点间接或直接到达,故是一个强联通的题目,我们可以先用tar...

Falcon的博客 391

POJ2186 Popular Cows (强连通缩点)

大意:给定n头牛,牛之间为有向的羡慕关系并且关系可以传递,问最后有多少个牛被所有的牛羡慕。 思路:羡慕的关系链或者环都可以进行缩点,使得图抽象DAG(有向无环图)。每个节点就是一个联通分量,我们统计每个联通分量的出度,当出度为0的连通分量数目大于1时就表明不是所以牛都羡慕其中的一头牛,结果为0。否则,我们直接找到最后缩点后的图中有多少个点就是最终的结果。 #in

Grit_ICPC的博客 529

Poj 2186 Popular Cows(Tarjan 强连通缩点)

传送门:Poj 2186 题意:给你n头牛,m种关系,A牛认为B牛是popular的,B牛认为C牛是popular的,则A也认为C是popular的,问最终有几头被所有牛认为是popular的牛 题解:强连通缩点基础题(虽然我Tarjan和缩点都是对的,但是最终讨论判断的时候写垮了(写了3天。。。。还不是你懒!!!!过年划水这么多天缩点后找出度为零的点个数。然后讨论是否有这样子的点,如果没有则...

weixin_34010949的博客 245

【强连通缩点】Popular Cows POJ2186

Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Description Every cow's dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, y

Jiangzh_MZOI 726

poj 2186 Popular Cows 强连通缩点

【题意】;给出一群牛中,一头牛认为另一头牛受欢迎的m对关系,关系式可以传递的,即若a认为b受欢迎,b认为c受欢迎,那么a也认为c受欢迎。求最多有多少头牛被所有的牛认为受欢迎。 【思路】:把这些关系形成的强连通图缩成点,就形成了一有向无环图,这个图里的出度为0的点(有且只有一个)就是被所有牛认为受欢迎的点,说明若这个点原来是强连通图就要求出这个强连通图里的总点数, 1 #include&l...

weixin_30319097的博客 144

poj 2186 Popular Cows(强连通缩点)

Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 23392   Accepted: 9580 Description Every cow's dream is to become the most popular cow in the he

听自己心跳的声音 639

POJ-2186 Popular Cows (强连通缩点)

Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18813 Accepted: 7570 Description Every cow's dream is to become the most popular cow in the herd...

weixin_30502965的博客 98

poj 2186 Popular Cows

一道强连通缩点的题。 一开始考虑强连通缩点了,不过思路不是很清晰。 题目就是求 其余所有点能到达的点有几个。 如果这是一个倒树(不知道有没有这个概念,自己理解的,就是树的边反向),那么树根结点就为树上点均可到达的点。所以我们的思路为:进行强连通缩点,因为强连通两两可到达,所以缩点之后的点即可代表那条分支上的点。 1、缩点之后如果出度为0的点只有一个,那么这个点所在的强连通分量

烟杀流年 882

poj2186 Popular Cows (Tarjan )

题目链接:http://poj.org/problem?id=2186 思路:

Delacour_的专栏 504

POJ 2186 Popular Cows(强连通)

POJ 2186 Popular Cows 题目链接 题意:一个奶牛,之间有互相仰慕的关系,如果A仰慕B,B仰慕C,意味着A也仰慕C,问有多少奶牛被所有奶牛仰慕 思路:强连通缩点,点权为连通集合个数,如果出度为0的点个数大于1个,答案就是0,如果等于1个,答案就是那个点的权值 代码: #include #include #include #include #i

Remilia's 905

poj 2186 Popular Cows 【强连通】

题目:poj 2186 Popular Cows 题意:n头牛,其中存在一些牛相互崇拜,具有传递性,问有多少头牛是被其他所有牛崇拜的。 分析:建立一个有向图,然后强连通缩点,之后求出度为0的点,假如存在多个,那么ans = 0,因为缩点之后如果x崇拜y,x也崇拜z,那么肯定y和z不能互相崇拜,不满足。 然后求出度为0的这个点缩点前环上有多少个点就ans AC代码:

大神养成中..... 1024
上一篇: poj 3352 Road Construction(双联通)
下一篇: 爸爸 妈妈 猎人和狗 有两男孩 两个女孩 。他们要过河,但猎人不在的时候,狗咬任何人,当爸爸不在的时候,妈妈打小男孩,妈妈不在的时候,爸爸打小女孩,他们怎么过去
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值