$dfs$。

记录一下每一个节点的深度就可以了。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std; int n;
int dep[],in[];
vector<int>g[]; void dfs(int x,int y)
{
dep[x]=y;
for(int i=;i<g[x].size();i++)
dfs(g[x][i],y+);
} int main()
{
while(~scanf("%d",&n))
{
for(int i=;i<=;i++) g[i].clear();
memset(in,,sizeof in); for(int i=;i<=n;i++)
{
int A,B; scanf("%d%d",&A,&B);
g[B].push_back(A);
in[A]++;
} for(int i=;i<=;i++)
{
if(in[i]==)
{
dfs(i,);
}
} if(dep[]==dep[]) printf("You are my brother\n");
else if(dep[]>dep[]) printf("You are my elder\n");
else printf("You are my younger\n"); } return ;
}

NBUT 1218 You are my brother的更多相关文章

  1. NBUT 1218 You are my brother 2010辽宁省赛

    Time limit 1000 ms Memory limit 131072 kB Little A gets to know a new friend, Little B, recently. On ...

  2. You are my brother NBUT - 1218

    问题描述 Little A gets to know a new friend, Little B, recently. One day, they realize that they are fam ...

  3. NBUT 1457 莫队算法 离散化

    Sona Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Submit Status Practice NBUT 145 ...

  4. fzoj1314 You are my brother

    题目描述 Little A gets to know a new friend, Little B, recently. One day, they realize that they are fam ...

  5. ACM: NBUT 1107 盒子游戏 - 简单博弈

     NBUT 1107  盒子游戏 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  6. ACM: NBUT 1105 多连块拼图 - 水题 - 模拟

    NBUT 1105  多连块拼图 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  7. 远程监控显示brother数控机床数据

    最近几个月公司太忙了,到现在已经连续出差两个多月了. 这个项目这要做mes系统,涉及到产品在机床的加工过程监控,然后led看板显示产品进度. 这里的主角是日本的brother数控机床,服务器按照一定频 ...

  8. 图论 --- spfa + 链式向前星 (模板题) dlut 1218 : 奇奇与变形金刚

    1218: 奇奇与变形金刚 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 130  Solved: 37[Submit][Status][Web Boa ...

  9. 【CodeVS 1218】【NOIP 2012】疫情控制

    http://codevs.cn/problem/1218/ 比较显然的倍增,但是对于跨过根需要很多讨论,总体思路是贪心. 写了一上午,不想再说什么了 #include<cstdio> # ...

随机推荐

  1. svn: Checksum mismatch while updating 错误

    最近使用svn客户端更新代码的时候出现 Checksum mismatch while updating 的错误 解决办法 在出错文件的目录下,用update to reversion , 先选onl ...

  2. iOS 隐藏导航栏下的黑线

    一.找到导航栏下的黑线 // 寻找导航栏下的黑线 - (UIImageView *)findHairlineImageViewUnder:(UIView *)view { if ([view isKi ...

  3. 【Zigbee技术入门教程-02】一图读懂ZStack协议栈的核心思想与工作机理

    [Zigbee技术入门教程-02]一图读懂ZStack协议栈的核心思想与工作机理 广东职业技术学院  欧浩源   Z-Stack协议栈是一个基于任务轮询方式的操作系统,其任务调度和资源分配由操作系统抽 ...

  4. jQuery清空表单方法

    $(':input', '#form1') .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked') .rem ...

  5. javascript工厂模式、单例模式

    //工厂模式 function createObject(name,age){ var obj = new Object(); obj.name = name; obj.age = age; obj. ...

  6. devinet_ioctl

    Kernel: 4.12.6 deinet_ioctl:获取或者设置接口的地址,掩码,标记等信息: 注意,使用SIOCSIFFLAGS关闭设备,如果使用了别名,则删除对应ip,如果其为主ip,并且从i ...

  7. 源码分析之tinyhttpd-0.1

    1. 简介: tinyhttpd是使用c语言开发的超轻量级http服务器,通过代码流程可以了解http服务器的基本处理流程, 并且涉及了网络套接字,线程,父子进程,管道等等知识点: 项目地址:http ...

  8. python实战===百度文字识别sdk

    http://ai.baidu.com/docs#/OCR-Python-SDK/top

  9. (十七)vmware无法将网络更改为桥接状态

    故障现象,导致虚拟机无法正常上网 设备管理器中的驱动设备正常加载,但是注意这两个虚拟网卡是有问题的 将这两个虚拟网卡删除 只剩物理网卡了,重新启动电脑 将虚拟机里的网络设置删除 清空网卡后点击恢复默认 ...

  10. HDU 6186 CS Course 前缀和,后缀和

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给了n个数,然后有q个查询,每个查询要求我们删掉一个数,问删掉这个数后整个序列的与值,或值 ...