2186 Popular Cows 图的连通性
来源:互联网 发布:怎么做好数据分析 编辑:程序博客网 时间:2024/06/05 15:40
Description
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
* Lines 2..1+M: Two space-separated numbers A and B, meaning that A thinks B is popular.
Output
Sample Input
3 31 22 12 3
Sample Output
1
Hint
Source
void Tarjan(int u) //Tarjan
{
int v;
node[u].DFN=node[u].LOW=(++idx);
instack[u]=true;
stack[++top]=u;
for(Edge*p=node[u].first; p; p=p->next)
{
v=p->adj;
if(!node[v].DFN)
{
Tarjan(v);
if(node[v].LOW<node[u].LOW)
node[u].LOW=node[v].LOW;
}
else if(instack[v]&&node[v].DFN<node[u].LOW)
node[u].LOW=node[v].DFN;
}
if(node[u].DFN==node[u].LOW)
{
b_cnt++;
do
{
v=stack[top--];
instack[v]=false;
node[v].belongs=b_cnt;
}
while(u!=v);
}
}
for(i=1; i<=N; i++)
{
flag[i]=true;
for(Edge*p=node[i].first; p; p=p->next)
if(node[i].belongs!=node[p->adj].belongs
&&hash[node[i].belongs]!=node[p->adj].belongs)
{
hash[node[i].belongs]=node[p->adj].belongs;
InsertEdge2(node[i].belongs,node[p->adj].belongs);
}
else
if(node[i].belongs==node[p->adj].belongs&&!flag[p->adj])
{
now[node[i].belongs].sum++;
flag[p->adj]=true;
}
}
- 2186 Popular Cows 图的连通性
- PKU 2186 Popular Cows
- POJ 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- POJ 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- POJ 2186(Popular Cows)
- POJ 2186 Popular Cows
- poj 2186 Popular Cows
- poj 2186 Popular Cows
- POJ 2186 Popular Cows
- POJ 2186: Popular Cows
- poj 2186 Popular Cows
- 《数字技术与应用》征稿函
- [Transfer]国际顶级会议列表(计算机相关)
- const 对象定义在头文件中
- 《数字技术与应用》征稿函
- jQuery技巧总结
- 2186 Popular Cows 图的连通性
- TCP/IP协议基本知识
- Microsoft_Dynamics_CRM 认证考试?!
- 蒙版2
- Google Android开发入门与实战
- 获得FaceSDK 3.0 的许可信息
- jquery实现股票的各种效果
- 感受
- ajax解析xml数据的两种对比